Re: joining and grouping

2008-02-28 Thread Olav Mørkrid
no that won't work, because even though the where excludes *my* vote for a particular candidate, it will include everybody else's vote for the same candidate. the objective is: if *i* voted for john, then john should not be in the final result set even though a million other people voted for

joining and grouping

2008-02-27 Thread Olav Mørkrid
hello i have a table vote which has the columns voter and candidate. i would like to make a list of the most popular candidates *except* those who are on my favorite list. using a sub-select, it's easy: my favorites: select candidate from vote where voter = '$me'; most popular: select candidate

Re: joining and grouping

2008-02-27 Thread Phil
I'm confused as to why you need the subselect at all? As it's all the same table why can't you just use select candidate,count(*) as total from vote where voter '$me' group by candidate order by total desc; On Wed, Feb 27, 2008 at 9:04 AM, Olav Mørkrid [EMAIL PROTECTED] wrote: hello i

Re: joining and grouping

2008-02-27 Thread Phil
Ok then, so select candidate,count(*) as total from vote where (voter '$me' and vote =1) group by candidate order by total desc; On Wed, Feb 27, 2008 at 9:37 AM, Olav Mørkrid [EMAIL PROTECTED] wrote: hi phil, i forgot to mention one thing. the table also has a column called vote which is

Re: joining and grouping

2008-02-27 Thread Olav Mørkrid
hi phil, i forgot to mention one thing. the table also has a column called vote which is either 0 (no vote given) or 1 (vote given). this column is required for other purposes. my favorites: select candidate from vote where voter = '$me' and vote = 1; most popular: select candidate from vote