逻辑运算符
- and
- or
- not
例子
- 查询编号大于3的女同学
两个条件:编号大于3 and 性别女
select * from students where id>3 and gender=0; - 查询编号小于4或没被删除的学生
select * from students where id<4 or isdelete=0;
模糊查询
- like 关键字
- %表示多个任意字符(字符可以任意,字符的个数也可以任意 0到多个)
- _表示一个任意字符(字符可以任意,字符的个数为1个)
例子
- 查询姓黄并且名字是一个字的学生
select * from students where sname like ‘黄_’;
两个字:添加两个下划线
select * from students where sname like ‘黄__’; - 查询名字包含 蓉 的学生
select * from students where sname like ‘_蓉_’; - 查询姓黄的或者叫静的学生
select * from students where sname like ‘黄%’ or sname like '%静%‘;