Bug #29586 MySQL ignores ORDER BY when field is quoted

Submitted: 5 Jul 2007 22:25 Modified: 5 Jul 2007 22:47
Reporter: Jan Bolmeson Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.21-log AND 5.0.41-community-nt OS:Any
Assigned to: CPU Architecture:Any
Tags: ignores, order by, quote

[5 Jul 2007 22:25] Jan Bolmeson
Description:
I have noticed that the two versions of MySQL (4.1.21-log & 5.0.41) server returns different results on this query:

SELECT * FROM `test` ORDER BY 'name'

It seems that when the field name is quoted it is ignored by the newer version whereas the old version (4.1) returns a correct sorted result.

I have googled as well as search in the bugdatabase but haven't found any information on the above subject.

Best regards,
Jan

How to repeat:
SQL Queries to reproduce:

CREATE TABLE `test` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(25) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

INSERT INTO `test` (`id`, `name`) VALUES 
(1, 'd'),
(2, 'c'),
(3, 'b'),
(4, 'a');

SELECT * FROM `test` ORDER BY 'name' <- Incorrect result in the newer version
SELECT * FROM `test` ORDER BY name  <- Correct results in both
[5 Jul 2007 22:47] MySQL Verification Team
Thank you for the bug report. Duplicate of bug: http://bugs.mysql.com/bug.php?id=29568

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.