我有这两张这样的桌子
test_table
date student test
2012-05-31 Alice Math
2012-05-31 Alice Math
2012-05-31 Bob Math
2012-05-31 Bob Spelling
2012-06-01 Alice Math
2012-06-01 Alice Spelling
score_table
date student test best_daily_score
2012-05-31 Alice Math 90
2012-05-31 Bob Math 50
2012-05-31 Bob Spelling 50
2012-06-01 Alice Math 95
我想检测到 Alice 的best_daily_score
测试Spelling
尚未2012-06-01
被记录。我正在寻找返回的查询
2012-06-01 Alice Spelling
这是唯一的一行
SELECT DISTINCT date, student, test FROM test_table
那不在
SELECT DISTINCT date, student, test FROM score_table
这不起作用:
SELECT DISTINCT date, student, test FROM test_table WHERE date, student, test NOT IN (SELECT DISTINCT date, student, test FROM score_table)
我假设因为左侧NOT IN
不应该是三件事的列表。