PHP MYSQL ORDER BY Multiple Columns

If you want to Order 2 or more columns in SQL Query. When ordering by more than one column, the second column is only used if the values are identical with the onces in the first column.

Example
[sql]
‘Order by Column
ORDER BY COLUMN1, COLUMN2
[/sql]

Order 2 or more columns with different orders

Example
[sql]
‘Order by Column
ORDER BY COLUMN1 ASC, COLUMN2 DESC
[/sql]

Permanent link to this article: https://blog.openshell.in/2011/09/php-mysql-order-by-multiple-columns/

Leave a Reply

Your email address will not be published.