1
我有表像這兩個選擇不同的三元組的補充在MySQL的
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)
我假設是因爲的左側不應該是三件事情的清單。