select 查询列表
from 表名
【where 筛选条件】
order by 排序的字段|表达式|函数|别名 【asc|desc】;
order by
1、asc代表的是升序,可以省略
desc代表的是降序
2、order by子句可以支持 单个字段、别名、表达式、函数、多个字段
3、order by子句在查询语句的最后面,除了limit子句
SELECT * FROM employees ORDER BY salary DESC;
SELECT * FROM employees ORDER BY salary;
SELECT *
FROM employees
WHERE department_id>=90
ORDER BY employee_id DESC;
SELECT *
FROM employees
WHERE department_id>=90
ORDER BY hiredate ASC;
SELECT *,salary*12*(1+IFNULL(commission_pct,0)) 年薪
FROM employees
ORDER BY salary*12*(1+IFNULL(commission_pct,0)) DESC;
或
SELECT *,salary*12*(1+IFNULL(commission_pct,0)) 年薪
FROM employees
ORDER BY 年薪 DESC;
SELECT *,salary*12*(1+IFNULL(commission_pct,0)) 年薪
FROM employees
ORDER BY 年薪 ASC;
SELECT LENGTH(last_name),last_name
FROM employees
ORDER BY LENGTH(last_name) DESC;
SELECT *
FROM employees
ORDER BY salary DESC,employee_id ASC;
本文系外文翻译,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系外文翻译,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。