Re: SQL optimization problem

2003-01-11 Thread Ryan Fox
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='' GROUP BY b.oid Ryan Fox - Original Message - From: "Blaster" <[EMAIL PROTECTED]> > However! Here comes the problem, if no vote is

Re: SQL optimization problem

2003-01-11 Thread Michael Brunson
LEFT JOIN On Sat, 11 Jan 2003 18:35:44 +0100, Blaster used a few recycled electrons to form: | Hey, | | (this post is pretty long, a short version of the problem is listed at the | bottom if you don't like reading long emails :P) | | I'm currently going through all my SQL queries for my webpa

Re: SQL optimization problem

2003-01-11 Thread Bhavin Vyas
You might have to tweak the following a bit for syntax: SELECT a.name, COUNT(b.id) as votes FROM poll_options as a LEFT JOIN poll_votes as b ON a.id=b.oid WHERE b.pid='' GROUP BY b.oid Also, you can refer to: http://www.mysql.com/doc/en/JOIN.html Bhavin. - Original Message - From: "