2
SELECT SUM(mark) AS totalMark, userID, credit
FROM users, marks
WHERE marks.receiverID = users.userID
AND userID = '2'
它將返回
totalMark userID credit
---------------------------
0 2 0.0
而這是非常好的,沒問題。但這裏的情況是2:
SELECT SUM(mark) AS totalMark, userID, credit
FROM users, marks
WHERE marks.receiverID = users.userID
AND userID = '-1'
結果:
totalMark userID credit
---------------------------
NULL NULL NULL
但我要的是什麼也不返回(找不到記錄)。任何人都可以幫助我?
任何時候,你會得到至少一排。 – Kermit 2013-03-07 18:32:45