将数据从一个表更新到另一个表(在数据库中)

将数据从一个表更新到另一个表(在数据库中),第1张

将数据从一个表更新到另一个表(在数据库中)

使用

exists
要继续处理到最低限度

沿着这些思路进行了一些修改,以使联接正确(也请验证我没有做任何愚蠢的事情,

TableA
并且
TableB
从您的描述中得到来回的信息):

insert into TableB    select         *    from        TableA a    where        not exists (select 1 from TableB b where b.ID = a.ID)delete from     TableB bwhere    not exists (select 1 from TableA a where a.ID = b.ID)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5675273.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存