时间:2021-07-01 10:21:17 帮助过:2人阅读
2、将A表中不存在于B表的记录,插入到B表中。
INSERT INTO B([序号], [日期], [IP], [部门], [操作员], [事件]) SELECT [序号], [日期], [IP], [部门], [操作员], [事件] FROM A WHERE NOT EXISTS (SELECT 1 FROM B WHERE A.[序号]=B.[序号]);
3、将B表中的记录一行一行更新到A表中。
UPDATE A SET A.[日期] = B.[日期], A.[IP] = B.[IP], A.[部门] = B.[部门], A.[操作员] = B.[操作员], A.[事件] = B.[事件] FROM A INNER JOIN B ON A.[序号]=B.[序号];
MySql:
UPDATE his_pet A, his_pet B SET A.Name = B.Name, A.NamePy = B.NamePy WHERE A.MID = B.MID
数据库同步相关的SQL语句
标签: