List:General Discussion« Previous MessageNext Message »
From:(S Date:March 31 2011 3:53pm
Subject:Re: Select with counts of matching rows from another table...
View as plain text  
>>>> 2011/03/23 16:29 -0700, Steffan A. Cline >>>>
So, this is what I have as a basis to work on assuming I am polling
article #36.
 
Select *, if(b.articleid=36,1,0) as checked from groups g
Left join agmap a on g.groupid=a.groupid
Left join articles b on a.articleid=b.articleid
Order by g.groupname
<<<<<<<<
Why not restrict it to '36': 'WHERE b.articleid = 36'?

As for the grouping, as it says in its helptext about MySQL s permissive 'GROUP BY', the
choice for any thus allowed field --one forbidden by the standard-- is random. (It
happens I have a case where that is just what I want: I do not care which value is shown,
as long as it goes with the rest.) Maybe you want 'articleid', too, in the grouping?

Thread
Select with counts of matching rows from another table...Steffan A. Cline24 Mar
  • Re: Select with counts of matching rows from another table...hsv31 Mar
    • Re: Select with counts of matching rows from another table...Reindl Harald31 Mar