SQLite Order By
SQLite 的 ORDER BY 子句是用来基于一个或多个列按升序或降序顺序排列数据。
语法
ORDER BY 子句的基本语法如下:
SELECT column-list FROM table_name [WHERE condition] [ORDER BY column1, column2, .. columnN] [ASC | DESC];
- ASC 默认值,从小到大,升序排列
- DESC 从大到小,降序排列
您可以在 ORDER BY 子句中使用多个列,确保您使用的排序列在列清单中:
SELECT select_list FROM table ORDER BY column_1 ASC, column_2 DESC;