[thelist] mySQL queries

rudy r937 at interlog.com
Mon Aug 12 21:44:01 CDT 2002


> For the sake of interest, what's the Best Way to write this query?

always match the GROUP BY to the SELECT

> Should I add more detail to my GROUP BY clause? Or is that
> unnecessary because I haven't SELECTed any non-aggregate
> columns from the invoice table?

doesn't matter where they come from, all non-aggregate columns in the
SELECT list should be in the GROUP BY

i'm pretty sure your query will still work right if you fix it

it's a good habit to get into, and will avoid those situations where "any
possible value for this group" are not what you expect -- which could
happen easily when one-to-many relationships are involved

rudy




More information about the thelist mailing list