Mysql 8: ORDER BY
Written by: maffelu , 2009-04-16 21:16:45
|--------------------+--------------------+--------------------|
|Name |Age |Gender |
|____________________+____________________+____________________|
|Bob 34 Male |
|Silvia 67 Female |
|Magnus 24 Male |
|Lisa 32 Female |
+--------------------------------------------------------------+
SELECT *
FROM person
ORDERY BY Name Asc
| Name | Age | Gender |
|---|---|---|
| Bob | 34 | Male |
| Lisa | 32 | Female |
| Magnus | 24 | Male |
| Silvia | 67 | Female |
SELECT *
FROM person
ORDER BY Age ASC
|--------------------+--------------------+--------------------|
|Name |Age |Gender |
|____________________+____________________+____________________|
|Bob 34 Male |
|Lisa 32 Female |
|Magnus 24 Male |
|Silvia 67 Female |
+--------------------------------------------------------------+
SELECT *
FROM person
ORDER BY Gender, Age ASC
|--------------------+--------------------+--------------------|
|Name |Age |Gender |
|____________________+____________________+____________________|
|Lisa 32 Female |
|Silvia 67 Female |
|Magnus 24 Male |
|Bob 34 Male |
+--------------------------------------------------------------+
SELECT *
FROM person
ORDER BY Gender ASC, Age DESC
|--------------------+--------------------+--------------------|
|Name |Age |Gender |
|____________________+____________________+____________________|
|Silvia 67 Female |
|Lisa 32 Female |
|Bob 34 Male |
|Magnus 24 Male |
+--------------------------------------------------------------+
There are no comments on this article.
If you have any question or just want to leave a message, just fill out the form below!
Your e-mail will not be visible in your post, it is for validation reasons only
Maffelu
Creator and admin of MorkaLork.com.
Started programming in HTML back when frames and tables was the way to design a page, moved on to Pascal/Delphi, PHP, javascript/jQuery, VB.NET/C#, Java and C++.
Currently studies .NET (in general) focusing on ASP.NET.