问题
Is there an operand/function/command in MySQL similar to the EXCEPT operand in SQL Server?
EXCEPT
returns any distinct values from the left query that are not also found on the right query.
This statement should give me the distinct values.
SELECT * FROM table1
EXCEPT
SELECT * FROM table2;
How can this be achieved in MySQL?
回答1:
The best you could do is use a NOT EXISTS
. Something like:
SELECT DISTINCT *
FROM table1
WHERE NOT EXISTS(SELECT NULL
FROM table2
WHERE table1.x = table2.x)
来源:https://stackoverflow.com/questions/6682084/similar-functionality-to-sql-servers-except-operand-in-mysql