Bug #41459 Order By clause has no effect..
Submitted: 15 Dec 2008 1:38 Modified: 15 Dec 2008 4:43
Reporter: David Baines Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1.30 Community Server OS:Linux (Open Suse 11.0)
Assigned to: Valeriy Kravchuk CPU Architecture:Any

[15 Dec 2008 1:38] David Baines
Description:
When executing a query, the "Order By" Clause has no effect on the returned data..

Works fine on Ver 5.0.18

mysql> select distinct luname from Leave.Applications limit 10;
+---------+
| luname  |
+---------+
| daveb   |
| brookea |
| carolg  |
| irenep  |
| rossw   |
| lindae  |
| kylieh  |
| jodyc   |
| jodiec  |
| jenw    |
+---------+
10 rows in set (0.00 sec)

mysql> select distinct luname from Leave.Applications order by 'luname' limit 10;
+---------+
| luname  |
+---------+
| daveb   |
| brookea |
| carolg  |
| irenep  |
| rossw   |
| lindae  |
| kylieh  |
| jodyc   |
| jodiec  |
| jenw    |
+---------+
10 rows in set (0.00 sec)
mysql> select distinct luname from Leave.Applications order by 'luname' DESC limit 10;
+---------+
| luname  |
+---------+
| daveb   |
| brookea |
| carolg  |
| irenep  |
| rossw   |
| lindae  |
| kylieh  |
| jodyc   |
| jodiec  |
| jenw    |
+---------+
10 rows in set (0.00 sec)
mysql> select distinct luname from Leave.Applications order by 'luname' ASC limit 10;
+---------+
| luname  |
+---------+
| daveb   |
| brookea |
| carolg  |
| irenep  |
| rossw   |
| lindae  |
| kylieh  |
| jodyc   |
| jodiec  |
| jenw    |
+---------+
10 rows in set (0.01 sec)

NB.
"Distinct" and "Limit" clauses only used to reduce the returned data for this bug report.
Problem still exists if these clauses are omitted.

How to repeat:
Create a new database
Create columns of type varchar and populate with random names.
Execute query to extract these names using "order by" clause.
[15 Dec 2008 4:10] Valeriy Kravchuk
Thank you for a problem report. Please, try to use

... order by luname

instead of

... order by 'luname'

and inform about the results.
[15 Dec 2008 4:20] David Baines
I have been requested to amend my query and report back..

Changing query to ....order by luname
instead of .... order by 'luname'

This has resolved the issue!!

Thanks for your help...

Dave