这是我当前的查询工作正常,但我需要它只返回quantity_to_spawn> 0当我添加一个where子句时,它通过消息给我一个无效的组。
我很高兴在必要时提供更多信息,但我不确定此时是否必要。 它是我正在写的游戏。
SELECT spawns.*, (quantity - COUNT(game_moblist.spawn_id)) AS quantity_to_spawn,mobs.*
FROM spawns LEFT JOIN mobs USING (mob_id) LEFT JOIN game_moblist USING (spawn_id) GROUP BY
spawn_id ORDER BY quantity_to_spawn DESC
答案 0 :(得分:2)
尝试添加having
而不是where
SELECT spawns.*, (quantity - COUNT(game_moblist.spawn_id)) AS quantity_to_spawn,
mobs.*
FROM spawns
LEFT JOIN mobs USING (mob_id)
LEFT JOIN game_moblist USING (spawn_id)
GROUP BY spawn_id
having quantity_to_spawn > 0
ORDER BY quantity_to_spawn DESC