ORDER BY Query Issues

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
curseofthe8ball
Forum Commoner
Posts: 73
Joined: Sun Jun 01, 2003 12:33 am

ORDER BY Query Issues

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
curseofthe8ball
Forum Commoner
Posts: 73
Joined: Sun Jun 01, 2003 12:33 am

Post by curseofthe8ball »

Feyd,

Is there any workaround or will we need to edit all our queries?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply