我有一张桌子,里面填充了用户写的品酒笔记,另一张桌子上还有其他用户给每个品酒笔记的评分。mySQL带回结果它不应该
,它提出了由您还没有评分看起来像这样其他用户写入的所有票据查询:
SELECT tastingNotes.userID, tastingNotes.beerID, tastingNotes.noteID, tastingNotes.note, COALESCE(sum(tasteNoteRate.Score), 0) as count,
CASE
WHEN tasteNoteRate.userVoting = 1162 THEN 1
ELSE 0
END AS userScored
FROM tastingNotes
left join tasteNoteRate on tastingNotes.noteID = tasteNoteRate.noteID
WHERE tastingNotes.userID != 1162
Group BY tastingNotes.noteID
HAVING userScored < 1
ORDER BY count, userScored
用户1162写了张便条做笔记113在tasteNoteRate表就说明起来就是:
noteID | userVoting | score
113 1162 0
,但它仍然是返回上述各运行查询时....
请仔细阅读关于使用SQL92兼容的'GROUP BY' – Kermit
我究竟应该在那里寻找什么@Kermit – Mike
我认为它也可能对您尝试实现以及尝试的解释有用这不符合你的期望。这种特定的方法可能完全被误导,并且可能有一种更简单的方法来做你正在尝试做的事情。 – moreON