Table of Contents
MySQL Order By:
When you use the SELECT statement to query data from a table, the result set is not sorted in any order. To sort the result set, you use the ORDER BY clause. The ORDER BY clause allows you to-
- Sort a result set by a single column or multiple columns.
- Sort a result set by different columns in ascending or descending order.
Syntax of MySQL Order By Clause:
SELECT * FROM table_name ORDER BY col1 ASC | DESC |
Example of MySQL Order By Clause for Ascending Order (ASC):

Example of MySQL Order By Clause for Descending Order (DESC):

MySQL Distinct:
When querying data from a table, you may get duplicate rows. In order to remove these duplicate rows, you use the DISTINCT clause in the SELECT statement.
Syntax of MySQL Distinct:
SELECT DISTINCT column_name FROM table-name |
Example of MySQL Distinct Clause:

Example of MySQL Order By and Distinct Clause:

Secondary Storage Devices Computer Memory Cloud Computing Information Security in E-Commerce Structured Programming Wireless Networking MySQL– Wikipedia |
Comments (No)