Re: outer join + count() + group by

2002-02-13 Thread Anvar Hussain K.M.
Hi, Yes I have made some mistakes. There was problem with the outer join. It should have been ad outer joined to review, not the other way. I didn't notice the first tabel person in the query. Try the following with two tables ad and review and later add person table. We don't know the column

Re: outer join + count() + group by

2002-02-12 Thread Jon Drukman
At 01:43 AM 2/12/2002, you wrote: >Hi, >Does this work for you? > >select ad.id,adtype,name,sum(review.id is not null) from person >review left join ad on ad.id=review.id >group by ad.id; this one returns 1 for the sum column no mater what. >select ad.id,adtype,name,sum(if (ifnull(review.id,0)=

Re: outer join + count() + group by

2002-02-12 Thread Anvar Hussain K.M.
Hi, Does this work for you? select ad.id,adtype,name,sum(review.id is not null) from person review left join ad on ad.id=review.id group by ad.id; OR select ad.id,adtype,name,sum(if (ifnull(review.id,0)=0,0,1)) from person review left join ad on ad.id=review.id group by ad.id; Anvar. At 06:13

outer join + count() + group by

2002-02-11 Thread Jon Drukman
i have what is basically a personal ad database. in one table, i have a list of advertisers. in another table i have a list of reviews. (there's a third table with stuff like their name, address, etc). i want to get a list of advertisers and the number of reviews all in one query. i can do