It's a shorthand way to say that I wanted to group on the first two 
columns of my select statement.


Here's a quote from the manual: 
http://dev.mysql.com/doc/mysql/en/SELECT.html

>>>
Columns selected for output can be referred to in ORDER BY and GROUP BY 
clauses using column names, column aliases, or column positions. Column 
positions are integers and begin with 1: 
mysql> SELECT college, region, seed FROM tournament
    ->     ORDER BY region, seed;
mysql> SELECT college, region AS r, seed AS s FROM tournament
    ->     ORDER BY r, s;
mysql> SELECT college, region, seed FROM tournament
    ->     ORDER BY 2, 3;
<<<

Since he had 3 columns in his SELECT clause but only the third one had an 
aggregate function applied to it, I "grouped" on the other two. I could 
have written it the long way as:

        GROUP BY _objectives.id, _objectives.name

Make sense?

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine



Mark Worsdall <[EMAIL PROTECTED]> 
11/10/2004 04:05 PM

To
[EMAIL PROTECTED]
cc

Subject
Re: Getting count() to include 0 counts in select






In message 
<[EMAIL PROTECTED]>, 
[EMAIL PROTECTED] writes
>
>Change one of your INNER JOINS to a LEFT JOIN. (The comma separated
>list of table names is actually a sneaky way to declare INNER JOINS).
>That way you will see all of the _objectives records whether or not
>they appear in _iso or any of the other tables.
>
>SELECT_objectives.id,
>       _objectives.name,
>       COUNT(go._iso._objective_id)
>FROM go._objectives
>INNER JOIN go._subjectHeadings
>        ON go._subjectHeadings.id = go._objectives.subjectHeadings_id
>INNER JOIN go._subjects
>        ON go._subjects.id = go._objectives.subjects_id
>LEFT JOIN go._iso
>        ON go._iso._objective_id = _objectives.id
>WHERE go._subjectHeadings.id = 276
>       AND go._subjects.id = 44
>GROUP BY 1,2
>ORDER BY go._objectives.displayOrder
>
[snip]

The group by 1,2

what is that all about the 1,2? is it join 1 and then join 2?



-- 
Work:- postmasterAThinwick.demon.co.uk

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]


Reply via email to