一、去重查询 select disint 列名 from 表名
二、条件查询
1.条件运算符:=>,<>,=,<=不等:<>,!=
2.算术运算符:+,-,*,%
3.逻辑运算符:and(&&),not(!),or(||)
范围查询:between...and.... in(范围....)不是范围是确定的值。
三、模糊查询
1.通配符:"." "[ ]" "[^]" "*" "+" "{n}" "^" "$"
2.使用like关键字
四、排序:order by 列名 asc升序(默认) desc降序
五、聚合函数和分组查询
1.count(*) 全部数据 max( )最大 min()最小 sun()求和 avg()求平均值
2.分组查询:group by having数据过滤,通常和分组group by后面
六、分页查询 limit
Select * from 表名 limit 索引,查询的个数(行数_,长度_)
七、多表联查
1.内连接 inner join on 关联条件 where过滤条件
2.外连接 ①左外连接 left join on
select * from 表1 left join 表2 on条件
②右外连接 right join on
select * from 表1 right join 表2 on条件
八、子查询
1.出现在其他语句中的select语句,称为子查询或内查询。外部的查询语句,称为主查语或外查询
2.联合查询 union合并去重 union all 不会去重
3.all子查询可以和=>,<>,=,<=,>,<使用
4.exists 和not exists 子查询