MySQL中的EXCEPT ALL等效项 [英] EXCEPT ALL equivalent in MySQL

查看:131
本文介绍了MySQL中的EXCEPT ALL等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个表,称为members,另一个表称为group.group的领导者也是成员

So I have a table called members and another table called group.The leader of the group is also a member

要检索不是领导者的成员,我做了以下工作 代码:

To retrieve members,who are not leaders I did the following code:

SELECT first_name, last_name, rank
FROM members
EXCEPT ALL
SELECT first_name, last_name, rank
FROM members INNER JOIN groups ON mid=leader;  --edited gid as mid 

在MySQL中执行此操作会给我带来语法错误.对于MySQL中的EXCEPT ALL,我应该使用什么?

Doing this in MySQL gives me a syntax error.What should I use for EXCEPT ALL in MySQL?

推荐答案

SELECT first_name, last_name, rank
FROM members 
LEFT OUTER JOIN groups ON gid=leader
WHERE leader is null

不确定groups表中是否是leadergid. groups表中的列必须在where子句中具有null校验.

Not sure if leader or gid is in the groups table. The column that is in the groups table must have a null check in the where clause.

这篇关于MySQL中的EXCEPT ALL等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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