查看表中所有字段数据
select * from 表名 where 条件;
查看表中部分字段数据
select 字段名1,字段名2;,..........., 字段名n from 表名 where 条件;
and 连接条件(并且)
关系运算符

在 值1,.......,值n 里
字段名 in(值1,.....值n里)

在 值1 和 值2 之间
字段名 between 值1 and 值2

为空 字段名 is null

不为空 字段名 is not null

模糊查询 %代替任意长度字符串
字段名 Like ".....%......";

查询_代替一个字符
字段名 Like "..._.....";

排序
select * from 表名 order by 字段名

正序排序
order by 字段名ASC

排序----倒序排序
order by 字段名DESC

限制条数
limit 条数

limit 偏移量,条数

去重
select distinct 字段名 from 表名

聚合函数
数量 count(字段名) count(* or 0)

求和 sum(字段名)

平均值 avg(字段名)

最小值 min(字段名)
最大值 max(字段名)

分组 group by 字段名 having 条件


为字段取别名(as可以省略)
字段名(可写函数)as 字段别名
查询Anna老师的上课教室
交叉连接
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.表1字段名 = 表明2.表明2字段名;

右连接
select * from 表明1 right join 表明2
on 表明1.表1字段名 = 表明2.表明2字段名;

查询Daniel老师的授课课程名

子查询 in
select * from 表名 where 字段 in (查询语句);

子查询 exists
select * from 表名 where exists (查询语句);

子查询 any
select * from 表名 where 字段 any (查询语句);

子查询 all
select * from 表名 where 字段 in (查询语句);











