Sorting can be single or more than one column in a table.The MySQL ORDER BY clause is used to sort the query result sets in either ascending or descending order.ORDER BY clause sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.
Syntax :
SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC|DESC
We can easly understand with given below example
output :
Explain code : In this example we set up the SQL query that selects the id, firstname and lastname columns from the Employee table ORDER BY firstname". where condtion order by sorting in by default ascending order then show it on output as we can see.
Output :
ORDER BY aslo using HTML TABLE for Example :
Output :