原表 table_A,目标表table_B
把table_A 的数据 写入 到table_B中
INSERT INTO table_B (字段1,字段2,字段3)
SELECT 字段1,字段2,字段3 FROM t_A
根据某些条件进行去重,假如根据两个表关联id
INSERT INTO table_B (字段1,字段2,字段3)
SELECT 字段1,字段2,字段3 FROM t_A as a
WHERE a.id NOT IN (SELECT id FROM table_B )
最后原表的数据发生更新时,对应目标表数据更新
update table_B as tb
set tb.字段1 = (select 字段1 from table_A as ta where tb.id = ta.id),
tb.字段2 = (select 字段2 from table_A as ta where tb.id = ta.id),
tb.字段3 = (select 字段3 from table_A as ta where tb.id = ta.id)