Dan,Thanks to Rhino & Dan for the corrections, HAVING in that query makes it >What do you mean? In SELECT foo ... GROUP BY foo ..., which row, of a group of rows with repeating foo values, is returned is "undetermined" (which means, roughly, it's determined by current physical ordering), unless there's an explicit within-group ordering as in your example. Here's a table of five rows with repeating values of id: SELECT * FROM chi; +----------+----+------+ | child_id | id | type | +----------+----+------+ | 1 | 1 | 0 | | 2 | 1 | 0 | | 3 | 1 | 1 | | 4 | 1 | 2 | | 5 | 2 | 2 | +----------+----+------+ Make a copy of the table which physically reverses row order: CREATE TABLE chi2 SELECT * FROM chi ORDER BY child_id DESC; SELECT * FROM chi2; +----------+----+------+ | child_id | id | type | +----------+----+------+ | 5 | 2 | 2 | | 4 | 1 | 2 | | 3 | 1 | 1 | | 2 | 1 | 0 | | 1 | 1 | 0 | +----------+----+------+ The two tables have identical data and opposite physical ordering, so SELECT ... GROUP BY id returns different rows: SELECT * FROM chi GROUP BY id; +----------+----+------+ | child_id | id | type | +----------+----+------+ | 1 | 1 | 0 | | 5 | 2 | 2 | +----------+----+------+ SELECT * FROM chi2 GROUP BY id; +----------+----+------+ | child_id | id | type | +----------+----+------+ | 4 | 1 | 2 | | 5 | 2 | 2 | +----------+----+------+ 2 rows in set (0.00 sec) Applying your query to chi1 and chi2, though, returns identical results. PB ----- Dan Bolser wrote: On Mon, 11 Apr 2005, Peter Brawley wrote: |
No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.6 - Release Date: 4/11/2005
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
