ORDER BY子句必须是SELECT语句中最后一条子句
1、排序数据
1 select 2 col_name 3 from 4 table_name 5 order by 6 col_name;
2、按多个列排序
1 select 2 col_name, 3 col_name2 4 from 5 table_name 6 order by 7 col_name. 8 col_name2;
3、按列位置排序
好处是不用再输入列名,但也存在局限性,不确定列名造成错列
1 select 2 col_name, 3 col_name2 4 from 5 table_name 6 order by 7 2,3;
4、指定排序方向
检索出的数据默认是按照升序输出的,可以更改为降序,使用DESC关键字,其关键字只应用到直接位于其前面的列名,如果要对多个列都进行降序排序,则每一列都必须指定DESC关键字
1 select 2 col_name, 3 col_name2 4 from 5 table_name 6 order by 7 col_name 8 desc;
标签:检索,name,name2,SQL,table,排序,col,select From: https://www.cnblogs.com/shixiaogu/p/16744759.html