ORDER BY Syntax for SELECT Query in MySQL


ORDER BY Syntax in Select Query can be used to arrange the data in Ascending or Descending order.

Example Table : For your reference


table_name
Column_name1Column_name2Column_name3Column_name4
1MalearticlesSam
2FemaledatabaseSam
3MalecodingJam
4MalecodingKam
5FemalecodingJam
Table Name is : table_name

ASCENDING ORDER 

Query : "SELECT * from table_name ORDER BY Column_name3"


or



Query : "SELECT * from table_name ORDER BY Column_name3 ASC"

If you execute the above query then Column_name3 data will be sorted in ascending order



table_name
Column_name1 Column_name2 Column_name3 Column_name4
1 Male articles Sam
3 Male coding Jam
4 Male coding Kam
5 Female coding Jam
2 Female Database Sam


DESCENDING ORDER 

Query : "SELECT * from table_name ORDER BY Column_name3 DESC"

If you execute the above query then Column_name3 data will be sorted in descending order



table_name
Column_name1 Column_name2 Column_name3 Column_name4
2 Female Database Sam
5 Female coding Jam
4 Male coding Kam
3 Male coding Jam
1 Male articles Sam




Comments

Popular posts from this blog

Five More Indian Languages - Google Translate

Connect To JioFi Device Without Knowing The Passwords Using WPS