sql 把一个表中的某一列赋值到另一个表中的某一列
在同一个数据库中,我想复制一个表(表1)中的某一列,到另一个表(表2)中。表2的其他列要保留,只是把表2的一列的值,换为表1中的那1列。 update 表2 set (要插入的列名)= select 表1.某一列 from 表1 left jion 表2 on 表1和表2的关联 where ..... 或 update 表1 set 表1.列=表2.列 from 表2 where 表2.id=表1.id
例子: 表T1有F1,F2,F3 字段 表T2有F1 ,F4字段 现在把T2的F4字段赋值给T1表的F3字段,如下: update T1 set T1.F3=T2.F4 from T2 where T1.F1= T2.F1 |