语法
SELECT [ALL | DISTINCT] select_expr, select_expr, ...
FROM table_reference [WHERE where_condition] [GROUP BY col_list] [ORDER BY col_list] [CLUSTER BY col_list
| [DISTRIBUTE BY col_list] [SORT BY col_list]
]
[LIMIT number]
注意:
- 大小写不敏感。
- 可以写在一行或者多行
例子
查询所有列
select * from emp
查询指定列
select ename,hiredate from emp ;
别名
重命名一个列,便于记忆、理解、计算
例子-给列起别名
select deptno num,ename as name from emp;
由于当前查询结果中,不显示列,所以意义不大
例子-给表起别名
select deptno,ename from emp e;
select deptno,ename from emp as e;
由于当前查询结果中,不显示列,所以意义不大
运算符
A+B 加A-B 减A*B 乘A/B 除A%B A 对 B 取余
例子
select ename,sal+comm from emp;