我有两张桌子:
TableA有两个列:“ AnswerId”,“ Date”。TableB具有两个列:“ Id”,“ OldDate”。
这是我到目前为止所得到的:
update TableA
set TableA.Date = TableB.OldDate
where TableA.AnswerId = TableB.Id
但这只会更新一行。如何使用TableB中的相关值更新TableA中的所有行?我真的不想每行手动执行此操作,因为我有数千行。
我不知道您的查询可能如何工作,因为tableB
未定义。
您可以使用一个显式的join
:
update TableA a join
TableB b
on a.AnswerId = b.Id
set a.Date = b.OldDate;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句