除了MySQL中的操作数之外,SQL Server还有类似的功能吗?

时间:2021-09-30 19:18:02

Is there an operand/function/command in MySQL similar to the EXCEPT operand in SQL Server?

MySQL中是否有一个操作数/函数/命令与SQL Server中的EXCEPT操作数相似?

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?

如何在MySQL中实现这一点?

1 个解决方案

#1


4  

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)

#1


4  

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)