Scroll to top
mysql

How to sorting in descending and ascending in sql?

Sorting in descending order in SQL

 

The ORDER BY statement in sql is used to sort the fetched data in either ascending or descending according to one or more columns.

  • By default ORDER BY sorts the data in ascending order.
  • We can use the keyword DESC to sort the data in descending order and the keyword ASC to sort in ascending order.
Descending

“select * from $dealtable where user_id=’$uid’ AND status=’$status’ ORDER BY ID DESC”

 

Ascending

“select * from $dealtable where user_id=’$uid’ AND status=’$status’ ORDER BY ID ASC”

Get more information

Read More Posts

Leave a Reply

Your email address will not be published. Required fields are marked *