Order By - in SQL
Dec 13th, 2008 by sherlock Hit :: 313
ms_user table
| user_id | username | area_id | |
| 1 | sherlock | c_sherlock@email.com | 1 |
| 2 | poirot | poirot@email.com | 2 |
| 3 | watson | b_watson@email.com | 1 |
| 4 | hasting | hasting@email.com | 2 |
| 5 | mycroft | a_mycroft@email.com | 1 |
SELECT * FROM `ms_user`
ORDER BY `area_id` , `email` DESC , `username`;
have the result ::
| user_id | username | area_id | |
| 1 | sherlock | c_sherlock@email.com | 1 |
| 2 | watson | b_watson@email.com | 1 |
| 5 | mycroft | a_mycroft@email.com | 1 |
| 3 | poirot | poirot@email.com | 2 |
| 4 | hasting | hasting@email.com | 2 |