数量 count(字段名) count(* or 0)
求和 sum(字段名)
sum (字段名),count(字段名)
平均 avg(字段名) 平均值avg=sun÷count
最大值() 最小值()
分组 group by 字段名
group by 字段名 条件(having); 使用where会发生冲突错误
为字段取别名(as可以省略)
字段名(可写函数) as 字段别名
查询Daniel老师的上课教室
给表取别名 (as可省略)
表名 as 表别名
交叉连接 (cross join)
select * from 表名1 cross join 表名2;
内连接 (inner join) (字段相等)
select * from 表名1 inner join 表名2
on 表名1.字段名 = 表名2.字段名;
左连接 (查询内容必须为主表内有的内容)
select * from 表名1 left join 表名2
on 表名1.字段名 = 表名2.字段名;
右连接
select * from 表名1 right join 表名2
on 表名1.字段名 = 表名2.字段名;
查询Daniel老师的授课课程名
子查询 in (先执行括号里的)
select * from 表名 where 字段 in (查询语句);
子查询 exists"存在"
select * from 表名 where exists (查询语句);
子查询 any
select * from 表名 where 字段 (> or < or.....)any (查询语句);
子查询 all