我有两个表StudentProgress
和Songs
。我想选择所有结果,其中可以加入从Songs
到StudentProgress
,并没有两个表连接,也StudentID
从StudentProgress
所有结果有一个特定的值..选择哪里id不存在,它的值是'特定值'
这是我为我的第一个表的代码效果很好
select
s.SongID,
s.Title,
s.Location,
s.Rhythm
from
Songs s
join
StudentProgress f on s.SongID = f.SongID
where
f.StudentID = 17
现在我想从StudentProgres
表,该表没有在Songs
表中存在,也有特定的StudentID
值相同的选择。
我想这样
select
s.SongID,
s.Title,
s.Location,
s.Rhythm
from
Songs s
join
StudentProgress f on s.SongID = f.SongID
where
f.StudentID is null
and f.studentid = 17
但我没有得到任何结果。
在这里看到的截图来了解
第二个查询中的WHERE子句无效。 'f.StudentID'不可能是NULL和17. –
我需要他们两个。我的意思是studentid = 17而不存在表歌曲 – user6453020
当你正在寻找歌曲表中不存在的东西时,你不能从's.SongID'之类的's'项目返回项目。你的问题陈述是反向的吗? – NetMage