Jump to content


group by, question..

  • Please log in to reply
1 reply to this topic

#1 leeming

  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 28 August 2006 - 03:36 AM

im wanting to run a query where the group by returns values in these groups (eg) 1/2/3/4.. even if the value is 0....

kinda hard to explain if you dont understand the above..
this is my code...
SELECT count( side ) AS cntTeam, side FROM `users` WHERE game = '$game' GROUP BY side ORDER BY cntTeam ASC LIMIT 1

basicly when new users play, they are put on the side with the least number of players... but the group by doesnt return 0 values (???)...
im wanting it to return results some thing like

team1= 0

So am i looking for a HAVING addition to my query?
Im not perfect ;) lol

#2 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 August 2006 - 10:21 PM

I don't understand.. you have an order by/limit... I'm confused.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users