问题出在" EXCEPT"这不受MySQL支持。目标是找到所有列(除了id)不相同的所有行。
SELECT B.*, 'modified' AS 'changetype'
FROM (
SELECT * FROM table1
EXCEPT
SELECT * FROM table2
) S1
INNER JOIN table2 B ON S1.id = B.id;
答案 0 :(得分:1)
这很棘手。您将不得不列出MySQL中的所有列。这可能是你最接近你想要的:
select t2.*
from table2 t2
where not exists (select 1
from table1 t1
where t1.id = t2.id and
t1.col1 = t2.col1 and
t1.col2 = t2.col2 and
. . .
);