PHP MySQL Order By
The function mysql_query() is used to execute select query with order by clause. mysql_query() function is deprecated. It is recommended to use one of the 2 alternatives.
- mysqli_query()
- PDO::__query()
The order by clause is used to fetch data in ascending order or descending order on the basis of column.
Syntax
SELECT * FROM table_name order by column_name(s) ASC
Let's see the query to select data from tbl_emp table in ascending order on the basis of name column.
Let's see the query to select data from tbl_emp table in descending order on the basis of name column.