order by + 数字 的意思

mysql官方文档如下:

select_expr [, select_expr …] [FROM table_references
[WHERE where_condition]
[GROUP BY {col_name | expr | position} [ASC | DESC], … [WITH ROLLUP]] [HAVING where_condition]
[ORDER BY {col_name | expr | position} [ASC | DESC], …]

order语句中position与col_name是替代关系,它代表select后边的参数位置.
group语句中position的含义相同



实例

SELECT a, b FROM t
GROUP BY 2
ORDER BY 2

语句中的两个2都表示b字段

你可能感兴趣的:(【Something】)