[thelist] sql sum() / group by / left join problem
rudy
rudy937 at rogers.com
Wed Sep 3 07:25:31 CDT 2003
> Anyone has an idea what happened?
the additional tables introduce a one-to-many effect
in your original query, you were grouping on the artist, and that gave you
one row per artist
one of the additional tables (genre?) has multiple rows per artist
so each artist is represented three times, once per genre, and then each of
those rows is joined to the songs, hence you have 162 instead of 54
in mysql, without subqueries, you could put the counts into a temp table,
and then join that with the others
however, it might be better to resolve how you intend to display the artist
three times instead of once
and don't forget, every non-aggregate column in the SELECT list has to be
included in the GROUP BY
rudy
More information about the thelist
mailing list