Order By clause in MYSQL by R4R Team

MYSQL ORDER BY CLAUSE:
-MYSQL ORDERBY CLAUSE is used to sort the data of the column in ascending or descending order.

Syntax:
SELECT columns
FROM table_name
WHERE conditions
ORDER BY column[ ASC | DESC];

Without ORDER BY:

SELECT * FROM employee;

emp_id emp_name department emp_salary
1 Aman D1 34000
2 Ram D2 43000
3 Ramesh D3 20000
4 John D4 65000
5 Sita D5 10000

Now, display the records in ascending order of the Employee Salary.

SELECT * FROM employee ORDER BY emp_salary;

emp_id emp_name department emp_salary
5 Sita D5 10000
3 Ramesh D3 20000
1 Aman D1 34000
2 Ram D2 43000
4 John D4 65000



Leave a Comment: