mysql order by multiple columns code example
Example 1: mysql order by multiple columns
SELECT * FROM table_name ORDER BY col1 ASC; -- ASCending is default
SELECT * FROM table_name ORDER BY col1 DESC; -- DESCending
SELECT * FROM table_name ORDER BY col1 DESC, col2 ASC; -- col1 DESC then col2 ASC
Example 2: ascending order mysql
SELECT
column_name1, column_name2, column_name3
FROM
table_name
ORDER BY
column_name1 [ASC|DESC],
column_name2 [ASC|DESC],
...;
Example 3: mysql multiple order by
ORDER BY col1, col2 DESC, col3;