Re: Maintaining sort order with 'GROUP BY' and 'HAVING'

2008-12-04 Thread Nishikant Kapoor
Its been a while since I posted this. Would like to check again with the folks on this list if they know why the results of query (b) are all blank on MySQL 5.0.22. It works fine with 5.0.51a. If it is a bug in 5.0.22, can someone suggest a workaround for this (other than upgrading MySQL).

Re: Maintaining sort order with 'GROUP BY' and 'HAVING'

2008-12-04 Thread Andy Shellam
Hi Nishi, I think what's more relevant is why did you downgrade to 5.0.22? The sorting issue you're experiencing was fixed for the 5.0.67 community release. Many bugs will have been fixed between 5.0.22 and 5.0.51a; downgrading is not a solution. Upgrade. If this is a new system you

Maintaining sort order with 'GROUP BY' and 'HAVING'

2008-11-27 Thread Nishikant Kapoor
CREATE TABLE t ( id TINYINT, title VARCHAR(10) ); INSERT INTO t (id, title) VALUES (1, 'aaa'), (2, 'bbb'), (3, 'ccc'), (4, 'ddd'), (5, 'eee'); (a) DO @sn := 0; SELECT @sn:[EMAIL PROTECTED] sn, id, title FROM t GROUP BY id ORDER BY id desc; | sn | id | title | +--+--+---+ |1

Re: Maintaining sort order with 'GROUP BY' and 'HAVING'

2008-11-27 Thread Andy Shellam
Hi Nishi, There was a bug in that version that affected the sort order when combined with a group by statement (http://bugs.mysql.com/bug.php?id=32202.) There are a couple of workarounds but they are bad (e.g. removing primary key!) I would strongly suggest you upgrade to 5.0.67 or

Re: Maintaining sort order with 'GROUP BY' and 'HAVING'

2008-11-27 Thread Nishikant Kapoor
Looking further for more info on this issue reveals that there is a bug in MySQL 5.0.51: http://bugs.mysql.com/bug.php?id=32202 which got fixed in 5.0.52. Thanks, Nishi Nishikant Kapoor wrote: CREATE TABLE t ( id TINYINT, title VARCHAR(10) ); INSERT INTO t (id, title) VALUES (1, 'aaa'), (2,

Re: Maintaining sort order with 'GROUP BY' and 'HAVING'

2008-11-27 Thread Nishikant Kapoor
Thanks for the response, Andy. I am now using the SELECT subquery to fix that problem. However, when I run the following query (b) on 5.0.22, I don't get any results - with and without the fix. CREATE TABLE t ( id TINYINT, title VARCHAR(10) ); INSERT INTO t (id, title) VALUES (1, 'aaa'), (2,