select 子句1 from 子句2 [where 表达式1] [group by 子句3] [having 表达式2] [order by 子句4] [union 运算符] [into outfile 输出文件名] [limit [m,]n];
limit [m,] n :m是结果集中的下标,n是查询数量
1、匹配符like
通配符
当匹配串不包含通配符,用=取代like,用<>取代not like
2、正则表达式
where 字段名 regexp '模式串'
3、空值查询
where 字段 is [not] null
4、连接查询
select [all | distinct] * from table1,table2
select A.*, B.* from student A, sc B where A.sno = B.sno; 或者 select A.*, B.* from student A inner join sc B on A.sno = B.sno;
select A.sno from sc A, sc B where A.sno = B.sno and A.cno = 'C01' and B.cno = 'C04';
select [all | distinct] * from table1 left|right|full[outer] join table2 on table1.sno = table2.sno;
5、嵌套查询
select sname from student where exists( select * from sc where sno = student.sno and cno='C01'; )
6、集合查询
union intersect minus
参考资料:《MySQL数据库原理及应用》武洪萍