如何显示与另一个表中的行不匹配的行? [英] How to display rows which don't match a row in another table?
本文介绍了如何显示与另一个表中的行不匹配的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想展示不是病房经理的员工.
I want to display staff that are not ward managers.
我有这个查询,其中显示了病房管理员:
I have this query which displays ward managers:
SELECT Name, Grade, WardManager, StaffNo
FROM STAFF, WARD
WHERE WARD.WardManager = STAFF.StaffNo;
但是我不知道如何显示不是病房经理的员工.我尝试过将IS NOT,NOT LIKE,NOT IN等组合使用,但它们似乎都不起作用.
However I can't figure out how to display the staff who aren't ward managers. I have tried a combination of IS NOT, NOT LIKE, NOT IN etc and none of them seem to work.
推荐答案
我不确定我是否正确理解了表结构,但是当有人抱怨NOT IN
不返回任何行时,使用的列中的NULL值几乎总是一个问题用于IN
运算符.
Not sure I understand you table structure correctly, but when someone complains that NOT IN
returns no rows, it's almost always a problem with NULL values in the column used for the IN
operator.
尝试一下:
select *
from staff
where staffno not in (select wardmanager
from ward
where wardmanager IS NOT NULL)
这篇关于如何显示与另一个表中的行不匹配的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文