试图理解“全部除外".在SQL查询 [英] Trying to understand "except all" in sql query

查看:153
本文介绍了试图理解“全部除外".在SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了这个示例,但我不明白它的含义.

I came across this example and I don't understand what it means.

(SELECT drinker FROM Frequents)
     EXCEPT ALL
(SELECT drinker FROM Likes);

关系:经常性(饮料,酒吧),喜欢(饮料,啤酒)

relations: Frequents(drinker, bar), Likes(drinker, beer)

在这种情况下,ALL会做什么?结果与下面的查询有何不同?

What does the ALL do in this case? How is the result different from the query below?

(SELECT drinker FROM Frequents)
     EXCEPT
(SELECT drinker FROM Likes);

推荐答案

SQL EXCEPT运算符获取一个查询的不同行,并返回未出现在第二个结果集中的行. EXCEPT ALL运算符不会删除重复项.为了消除行和删除重复项,EXCEPT运算符不区分NULL.

The SQL EXCEPT operator takes the distinct rows of one query and returns the rows that do not appear in a second result set. The EXCEPT ALL operator does not remove duplicates. For purposes of row elimination and duplicate removal, the EXCEPT operator does not distinguish between NULLs.

EXCEPT ALL,它返回第一个表中所有不存在于第二个表中的记录,而重复项保持原样.不幸的是,SQL Server不支持该运算符.

EXCEPT ALL which returns all records from the first table which are not present in the second table, leaving the duplicates as is. Unfortunately, SQL Server does not support this operator.

这篇关于试图理解“全部除外".在SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆