MySQL Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Mysql Tutorial
Introduction
How to Install
Database
Datatypes
Tables
INSERT
SELECT
UPDATE
DELETE
Operators
Functions
Ask Your Doubts
Feedback
 





Order By MySQL


Tutorials Mysql

Topic
How to sort Table using MySQL Order By Clause?


Explanation

Order By MySQL :

    We can also sort multiple columns in different directions as given in the below MySQL Order by query.

mysql> select name, marks, address from student order by name,
marks desc;
+---------+-------+------------------+
| name    | marks | address          |
+---------+-------+------------------+
| anne    |   100 | downing street   |
| anne    |    80 | edinburgh        |
| david   |    98 | welling street   |
| jack    |    82 | victoria street  |
| michael |    75 | edinburgh        |
| mille   |    98 | victoria street  |
| steve   |   100 | 5th cross street |
| steve   |    75 | downing street   |
+---------+-------+------------------+
8 rows in set (0.00 sec)
    Here we have selected three columns name, marks and address. In this query we have sorted the column name alone in ascending order and we have additionally mentioned marks in descending order.

    So if there are same names, the highest mark will be taken as the first priority. In the above example query, there are 2 anne, so the anne with highest mark will be displayed first.





A Note

MySQL is the most popular open source Relational database Management system (RDBMS). Being a open source anyone can use and change the software for their needs. Hope you enjoy this tutorial. We welcome your Valuable feedbacks or suggestions on this MySQL tutorial. This is a copyright content.


Other Links

web hosting