假設以下MySQL表結構,爲什麼以下兩個查詢產生不同的結果?以下查詢是否應該產生相同的結果? (MySQL)
games(id) (464 records)
members(id) (1 record, id=351)
gameslists(id,memberid,gameid) -- (2 records, (1,351,1) and (2,351,2))
這會產生空
SELECT games.*
FROM games
INNER JOIN gameslists ON gameslists.gameid = games.id
WHERE gameslists.memberid <> 351 AND gameslists.id is NULL
這將產生462個記錄,這是我的期望。
SELECT games.*
FROM games
LEFT JOIN gameslists ON gameslists.gameid = games.id AND gameslists.memberid <> 351
WHERE gameslists.id is NULL
謝謝Daniel! – Mohamad 2010-09-12 22:00:19
@梅爾:什麼是產生錯誤? – 2010-09-12 22:00:56
不是,一個錯誤,但也爲空:LEFT JOIN gameslists ON gameslists.gameid = games.id WHERE gameslists.id爲NULL AND gameslists.memberid <> 352 – Mohamad 2010-09-12 22:02:00