List:General Discussion« Previous MessageNext Message »
From:Jon Haugsand Date:May 27 2003 12:48pm
Subject:Re: group by
View as plain text  
* Jose Miguel Pérez
> Hi Jon!
>
>> Actually, I got (A) by testing.  ;-)  However, should you?  The result
>> looks like it is arbitrary, and another day, you get (B).
>
>     Yes, looks arbitrary but really isn't. You are getting the first value
> of the group in no order. Add this to the query and see the result:
>
>         ... ORDER BY name DESC
>
>     (Note: When I say "in no order" I mean the order you get in "SELECT *
> FROM foo")

OK, thanks.

>     However, reading the MySQL manual, they explain why MySQL is so relaxed
> about the columns listed in the GROUP BY clause. Read the chapter "6.3.7
> Functions for use with GROUP BY clauses". There is clearly explained that
> the MySQL team choose not to force the existence of all columns in the GROUP
> BY for perfomance reasons. They also give an example there.
>
>     However, you can force MySQL to require a full GROUP BY by using the
> following parameter in the mysqld command line:
>
>         --sql-mode=ONLY_FULL_GROUP_BY
>
>     Or by forcing ANSI SQL compliance: --ansi

Hmm, I understand the performance issue, but I generally think it's
best to be as ANSI complient as possible.  Would it be wrong to
include an ANY function (as suggested)?

(But what is the ANSI explenation for having to include a full group
by list?  In the ANSI world you know _have to_ do like I said,
specifically give the list of columns to group by.)

-- 
 Jon Haugsand, Jon-H.Haugsand@stripped
 http://www.norges-bank.no

Thread
group byRob27 May
  • Re: group byJose Miguel Pérez27 May
    • RE: group byRob27 May
    • Re: group byJon Haugsand27 May
    • Re: group byDon Read27 May
  • Re: group byJose Miguel Pérez27 May
    • Re: group byJon Haugsand27 May
  • Re: group byJose Miguel Pérez27 May
    • Re: group byJon Haugsand27 May
  • Re: group byJose Miguel Pérez27 May