Entry
How can I reverse the sort order when using ORDER BY?
What are the ASC and DESC keywords for?
Jan 23rd, 2000 22:18
Nathan Wallace, Coke, Joshua Chamas
This query will return the rows from oldest to youngest when ordered by
the add time:
SELECT * FROM links ORDER BY add_time;
To return the rows in the opposite sort order (youngest to oldest) use
the DESC (descending) keyword:
SELECT * FROM links ORDER BY add_time DESC;
The default ordering is ASC (ascending). So you can add the ASC keyword
without changing the results. These commands are equivalent:
SELECT * FROM links ORDER BY add_time;
SELECT * FROM links ORDER BY add_time ASC;