以下是我要使用的查询,
select DISTINCT c.sno from Cards as c, reservation as r
where c.name='CRS-4-FC' AND c.sno != r.ssno;
该查询应该从保留表中不存在的卡中仅选择那些sno,即,保留表中ssno列中不存在sno。我把
c.sno!=r.ssno
这样我就不会选择所有的sno。但是,当该查询运行时,我得到所有的sno而不是那些没有保留的信息。有人可以帮忙我哪里出错了..
最佳答案
尝试
select DISTINCT c.sno
from Cards as c
left outer join reservation as r on c.sno = r.ssno
where r.ssno is null
and c.name='CRS-4-FC'