1,聚合函数
数量 select count (字段名)count (*、0)from 表名;
求和 select sum (字段名)from 表名;
平均值 select avg (字段名)from 表名;
最小值 select min (字段名) from 表名;
最大值 select max (字段名)from 表名;
分组 select 字段名,group by 字段名 having 条件;
2,为字段名取别名 (as可以省略)
select 字段名 (as)字段别名 from 表名 group by字段名;
3,表与表的连接
交叉连接
select * from 表名1 cross join 表名2;
内连接
select * from 表名1 inner join 表名2 on 表名1.表1字段名=表名2.表2字段名;
左连接
select * from 表名1 left join 表名2 on 表名1字段名= 表名2.表2字段名;
右连接
select * from 表名1 right join 表名2 on 表名1字段名= 表名2.表2字段名;
4,子查询 in
select * from 表名 where 字段 in(查询语句);
子查询 exists
select * from 表名 where exists (查询语句);
子查询 any
select * from 表名 where 字段>any(查询语句);
子查询 all
select * from 表名 where 字段>all (查询语句);