从学校表中获取非匹配记录(突出显示)

时间:2017-11-16 12:37:14

标签: sql sql-server

Tables

我想从表格'学校'中获取突出显示的记录。其主题不在Tution中。尝试左连接由于某种原因出错了。请有人帮忙吗。我正在使用sql server。

2 个答案:

答案 0 :(得分:4)

SELECT Student, Subject, Marks FROM School
EXCEPT
SELECT Student, Subject, Marks FROM Tution

答案 1 :(得分:-1)

尝试该查询:

SELECT * 
FROM TUTION  
WHERE MARKS NOT IN
(SELECT MARKS FROM SCHOOL WHERE MARKS IN(90,70) AND STUDENT NOT IN('PETER',JOHN'))