[英]How to translate this MSSQL query using "EXCEPT" to MySQL?
问题在于 MySQL 不支持的“EXCEPT”。 目标是找到所有列(id 除外)不相同的所有行。
SELECT B.*, 'modified' AS 'changetype'
FROM (
SELECT * FROM table1
EXCEPT
SELECT * FROM table2
) S1
INNER JOIN table2 B ON S1.id = B.id;
这很棘手。 您将不得不列出 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
. . .
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.