Table of Contents


I’m trying to have a blog page order it’s entries by the auto incremented unique ID given in descending order, it doesn’t seem to allow it. It always appears in ascending order despite the SQL request as written below:

SELECT * FROM news_blog ORDER BY 'news_id' DESC

Is it because the news id is an Integar and therefore doesn’t allow for ordering?


If you want to escape column or table names use backticks, not quotes

SELECT * FROM news_blog
ORDER BY `news_id` DESC

SQLFiddle demo

When using quotes the DB thinks you want to sort by the static string ‘news_id’ which is not sorting at all since it is the same for a records.

Answered By – juergen d

Answer Checked By – Katrina (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *