21.6 C
New York

MySQL ORDER BY Keyword

Published:

You want to sort the records then MySQL ORDER BY is the keyword to use.

You wish to specify the result arrangement which the MySql Select Command Query selects data from database.

Example

 SELECT * FROM Paymentmethod
ORDER BY paymenttype;

The sorting arrangement which the records or data selected and display are specified using a MySQL Keyword called ORDER BY.

2 Orders it sorts records are:

  1. Ascending (asc) order
  2. Descending (desc) order

You know that by default that the keywords sorts record in DESC(descending) order.

But to modify the order you may prefer to specify either ASC or DESC with represents ascending or descending respectively.

See the below code:

 SELECT * FROM Paymentmethod
ORDER BY paymenttype ASC;

ORDER BY ASC

 SELECT * FROM Paymentmethod
ORDER BY paymenttype DESC;

ORDER BY DESC

Godwin
Godwinhttps://shopinson.com
Owner and founder of shopinson.com. He is a passionate programmer with enthusiasm in daily discovering of solving logic with new block of codes. He loves creating contents and blogging his new discoveries on programming language and related peripherals.

Related articles

spot_img

Recent articles

spot_img