..<< = More Info = >>..

Wednesday, August 20, 2008

MySql The ORDER BY

The ORDER BY keyword is used to sort the result.

Sort the Rows
The ORDER BY clause is used to sort the rows.

Example
To display the company names in alphabetical order:
SELECT Company, OrderNumber FROM Orders
ORDER BY Company

Example
To display the company names in alphabetical order AND the OrderNumber in numerical order:
SELECT Company, OrderNumber FROM Orders
ORDER BY Company, OrderNumber

Example
To display the company names in reverse alphabetical order:

SELECT Company, OrderNumber FROM Orders
ORDER BY Company DESC

Example
To display the company names in reverse alphabetical order AND the OrderNumber in numerical order:

SELECT Company, OrderNumber FROM Orders
ORDER BY Company DESC, OrderNumber ASC

Source : w3schools.com

No comments:

Custom Search
 

Bursa 2000 | Find Better Jobs