Taking a blind stab, how about.. SELECT a.name, minimum(0,COUNT(b.id)) as votes FROM poll_options as a LEFT JOIN poll_votes as b on a.id=b.oid WHERE b.pid='<poll_id>' GROUP BY b.oid
Ryan Fox ----- Original Message ----- From: "Blaster" <[EMAIL PROTECTED]> > However! Here comes the problem, if no vote is cast on an option, it will > not show up in the list! I want it to print 0% > for any options that havn't received a vote, like it would with my old > query system. This is basically what I want to > do: > > SELECT a.name, COUNT(b.id) as votes FROM poll_options as a, poll_votes as b > WHERE b.pid='<poll_id>' AND b.oid=a.id GROUP BY b.oid > > With one exception, if votes = 0, it should be listed in the result aswell! sql, query --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php