条件查询
1、条件查询中用的非常多的是where条件查询,在where后可以使用and、or、not一类逻辑运算符来增加限定条件
select * from student where age=18 and gender=1;
2、对于where后面使用逻辑运算符的语句,可以通过加上括号来修改优先级。尤其是在not的使用中,如下面两条语句的输出结果是不同的
select * from student where not age=18 and gender=1;
select * from student where not (age=18 and gender=1);
3、模糊查询有两种方法,一是用like,在使用时,%替换一个或多个字符,_替换一个字符。具体使用示例如下
查询姓王的学生
select * from student where name like '王%';
查询姓名中包含王字的学生
select * from student where name like '%王%';
查询姓名为两个字的学生