MySQL之常用关键词
MYSQL的常用关键词:
distinct:去重
select distinct res.studentno FROM result res;
between关键词:在什么什么之间
select res.studentresult FROM result res where res.studentresult between 80 and 90;
like关键词:模糊查询,配合%使用,注意,使用like模糊查询后,索引会失效
select sub.subjectname from `subject` sub where sub.subjectname like '高%';
x%,意思是匹配高字开头的条件
select sub.subjectname from `subject` sub where sub.subjectname like '%等%';
两边都模糊查询,中间有关键词等
select sub.subjectname from `subject` sub where sub.subjectname like '%1';
模糊查询,查后面有1的数据
in关键词:
select * from result res where res.studentresult in (80,95,81,100);
意思是查询括号里的条件
is not null 和is null:
select * from student stu where stu.address is not null;
select * from student stu where stu.address='' or stu.address is null;