0

这是我当前的查询工作正常,但我需要它只返回 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
4

1 回答 1

2

尝试添加 ahaving而不是 awhere

  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
于 2012-07-12T18:53:01.257 回答