Easy MySQL Sorting Mistake

by damonp on April 5, 2007

If you have a compound ORDER BY clause with a direction (ASC or DESC), make sure to specify the directions of all columns.

Correct:

ORDER BY col1 DESC, col2 DESC

Wrong:

ORDER BY col1, col2 DESC

The latter forces a filesort.

Popularity: unranked [?]

Leave a Comment

Previous post:

Next post: