acctman
acctman

Reputation: 4349

How to fix syntax error near 'ORDER BY DESC'?

I'm running MYSQL version 5.5 and I am receiving the following errors. I have tried adding LIMIT 1 to the end, removing ORDER BY DESC specifying to sort by DATE(submit_date)... yet still I receive the same error.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY DESC' at line 1

SELECT status, DATE(submit_date) FROM ". $GLOBALS['TABLES']['APPLICATION'] ." WHERE fk_userid = $userId ORDER BY DESC

Upvotes: 0

Views: 4091

Answers (2)

sky
sky

Reputation: 26

You should indicate the column_name.

SQL ORDER BY Syntax:

SELECT column_name, column_name
 FROM table_name
 ORDER BY column_name ASC|DESC, column_name ASC|DESC;

from: http://www.w3schools.com/sql/sql_orderby.asp

Upvotes: 0

Tom Studee
Tom Studee

Reputation: 10452

You are missing a field in your order by clause : ORDER BY DESC

Either add a field: ORDER BY someField DESC or remove the ORDER BY DESC text.

Upvotes: 4

Related Questions