1SELECT * FROM table_name ORDER BY col1 ASC; -- ASCending is default
2SELECT * FROM table_name ORDER BY col1 DESC; -- DESCending
3SELECT * FROM table_name ORDER BY col1 DESC, col2 ASC; -- col1 DESC then col2 ASC
1SELECT * FROM table_name ORDER BY col1 ASC; -- ASCending is default
2SELECT * FROM table_name ORDER BY col1 DESC; -- DESCending
3SELECT * FROM table_name ORDER BY col1 DESC, col2; -- col1 DESC then col2 ASC
1
2 SELECT
3 column_name1, column_name2, column_name3
4FROM
5 table_name
6ORDER BY
7 column_name1 [ASC|DESC],
8 column_name2 [ASC|DESC],
9 ...;
1To get the sorted result from MySQL select statement we use order by clause with SELECT statement.
2
3Syntax:
4SELECT column_list FROM tablename ORDER BY column_name1 [ASC][DESC],column_name2 [ASC][DESC],...
1SELECT
2 select_list
3FROM
4 table_name
5ORDER BY
6 column1 [ASC|DESC],
7 column2 [ASC|DESC],
8 ...;