Scroll to top
mysql

How to sorting in descending and ascending in sql?


Notice: Undefined variable: string in /home/u665484253/domains/wpcodekit.com/public_html/wp-content/themes/twentytwenty-child/functions.php on line 61

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.