一.条件查询 where
1.等值查询 =
select * from student where id=1;
2.不等值查询 != (< >)
查询年龄不是20岁的学生信息
select * from student where age!=20;
3.关系比较查询 < <= > >=
查询年龄大于20岁的学生信息
select * from student where age>20;
4.逻辑运算查询 and or
and 满足所有条件 or只需要满足其中一个条件
查询年龄小于21岁并且住址是郑州
select * from student where age<21 and address="郑州";
查询年龄小于21岁或者住址是郑州的
select * from student where age<21 or address="郑州";
5.区间查询 between .. and (包含边界值)
查询年龄是18岁到21岁之间
select * from student where age between 18 and 21;
select * from student where age>=18 and age<=21;
6.模糊查询 like
① %(匹配0-n个字符)
查询学生表中名字包含x的学生信息
select * from student where stuname like '%x%';
② _ (匹配一个字符,相当于一个占位符)
查询学生表中地址第二个字为京的信息
select * from student where adderss like '_京';
2021-07-29
最新推荐文章于 2022-07-02 11:35:48 发布