update批量更新某一列成其它列对应的值【原】

update批量更新某一列成其它列对应的值

postgresql

标准sql语句

update AA set AA.name = BB.name , AA.sex = BB.sex  from  BB where AA.id = BB.id ;

注意不要写成 from AA,BB ,即不要把自身的表写在from后,不然会报异常 :table name specified more than once

update AA set name = BB.name from AA,BB where AA.id = BB.id 

oracle

标准sql语句,可以同时更新多个列

UPDATE BB set (name,sex) = (select CC.name, CC.sex from CC where CC.id = BB.id) where BB.id = 1

 SQL Server

update A SET A.COL1=B.COL1  FROM A,B where A.KEY=B.KEY where 其它条件限制

猜你喜欢

转载自www.cnblogs.com/whatlonelytear/p/11649747.html
今日推荐