table1ip parentip
6 | 2
3 | 2
5 | 3
2 | 1
table2ip newip
2 | 12
3 | 13
4 | 14
如何根据table2更新table1的ip和parentip就是说把table1中所有的ip换成table2中的newip。
6 | 2
3 | 2
5 | 3
2 | 1
table2ip newip
2 | 12
3 | 13
4 | 14
如何根据table2更新table1的ip和parentip就是说把table1中所有的ip换成table2中的newip。
set A.ip = B.newip
where A,parentip = B.ip
set table1.parentip = table2.parentip
or
update table1 A inner join table2 B on A.parentip = B.ip set A.ip = B.newip
SQL版本是 5.0.67
set A.ip = B.newip
where A.parentip = B.ip这样写的话,会报错,duplicate entry '12' for key1
修改了一下就可以了
谢谢楼上各位~