开发中经常遇到这种情况,举个例子,A表中有price,id字段,B表中有sub_price,id字段,需要把B表的sub_price根据id洗成price
update table1
set field1=(select field2 from table2 where table2.id=table1.id)
--> 如果需要约束A表的条件,可以在外面加where
where table1.id in (condition)
开发中经常遇到这种情况,举个例子,A表中有price,id字段,B表中有sub_price,id字段,需要把B表的sub_price根据id洗成price
update table1
set field1=(select field2 from table2 where table2.id=table1.id)
--> 如果需要约束A表的条件,可以在外面加where
where table1.id in (condition)