我想把表B中的两行更新到表A中去。表A和表B的关键行都是tagName下面的sql代码执行时提示
“You can't specify target table 'ybjy_detail_bake' for update in FROM clause”
请问该如何写呢?
update tableA set tableA.unit = (SELECT tableB.unitFROM tableB,tableA where tableB.tagName=tableA.tagName and tableB.Id=1)
最初由 luoxuanhua 发布
[B]我想把表B中的两行更新到表A中去。表A和表B的关键行都是tagName下面的sql代码执行时提示
“You can't specify target table 'ybjy_detail_bake' for update in FROM clause”
请问该如何写呢?
update tableA set tableA.unit = (SELECT tableB.unitFROM tableB,tableA where tableB.tagName=tableA.tagName and tableB.Id=1) [/B]
update a set a.col = (select col from b where a.id=b.id) where exists (select * from b where a.id=b.id)
update (select a.col cola ,b.col colb from a,b where a.id=b.id) set cola=colb
要求b表(源表)有主键