Page 1 of 1

ORDER BY Query Issues

Posted: Sat Jun 16, 2007 11:54 pm
by curseofthe8ball
We recently changed servers for over 70 clients and this new server is running MySQL 4.1.22. A bunch, if not all, of all queries which consist of ORDER BY statements are failing to order as they should. Below is a sample of our code that worked fine on our previous server but now is giving us problems.

Code: Select all

$query = "SELECT * FROM jobs WHERE status = 'active' ORDER BY 'date_full' DESC"; 
$result = mysql_query($query) or die (mysql_error());
I believe I have pinpointed the issue to the 'date_full' DESC part as if I remove the single quotes or replace the single quotes with `, the query works properly.

My problem is that we have alot of clients and we've used this type of query for a ton of sites. Before I go through each and every site to remove the single quotes, is there any other solution? Please tell me there is... updating all of these sites would be a horrid task.

Posted: Sun Jun 17, 2007 12:05 am
by feyd
Single quotes (and double quotes) signify strings to MySQL. No quotes or backticks (`) signify a reference to a column, table and/or database.

Posted: Sun Jun 17, 2007 12:23 am
by curseofthe8ball
Feyd,

Is there any workaround or will we need to edit all our queries?

Posted: Sun Jun 17, 2007 12:27 am
by feyd
I don't know of a configuration directive that would support such a "feature," so I believe you will need to edit all the queries.