官术网_书友最值得收藏!

ORDER BY clause

The ORDER BY helps us in retrieving records in an ordered manner. This provides sorted data on a particular column in an ascending or a descending manner. By default, it will sort in ascending order but we can also explicitly specify the sorting manner with ASC and DESC keyword. If we specify ASC then it will sort in an ascending order while DESC keyword will sort in descending order. Here is the query which will find all users in a sorted manner in an ascending order on city column.

SELECT * FROM users ORDER BY city ASC;

Sorting in multiple columns is also possible using ORDER BY clause. We can pass multiple columns as shown in below query where we have ordered by city and username column.

SELECT * FROM users ORDER BY city, username;
主站蜘蛛池模板: 江口县| 金湖县| 许昌市| 博罗县| 镇赉县| 巫山县| 青川县| 金乡县| 越西县| 荆门市| 临洮县| 星子县| 阿尔山市| 临颍县| 乐业县| 健康| 宁安市| 巢湖市| 南充市| 英吉沙县| 汤原县| 安新县| 瑞安市| 灌南县| 珲春市| 通榆县| 拜城县| 周至县| 金阳县| 永福县| 江永县| 鸡东县| 通州市| 南开区| 兴义市| 信丰县| 达拉特旗| 乌什县| 九江县| 黄大仙区| 嵊州市|