比较运算符: = > < = <> != >= <=
逻辑运算符: and or not
模糊查询: like %(任意个字符) _单个字符
范围查询: in() , between ... and ...
空判断: is null
优先级: ()->not->比较运算符->逻辑运算符 (and比or先运算)
聚合函数: count() --统计总共有多少行
max() --最大值
min() --最小值
sum() --求和
avg() --求平均值
分组: group by --非分组列不能出现在结果集中,聚合函数可以出现在结果集中
分组后的删选: having
排序:order by asc --升序 desc--降序
分页: select * from tableName limit start,n --start从0开始计算,n条记录
完整的select 语句示例:
select distinct ...
from ...
where...
group by... having...
order by ...asc|desc
limit start,count
SQL语句的执行顺序:
- from tableName
- where...
- group by...
- select distinct ...
- having...
- order by...
- limit start, count