01.where 过滤
[toc]{type: “ol”, level: [2, 3, 4, 5]}
基础概念
select * from table_name\G 单独展示每一行的数据
书写顺序:
select id,name from emp where id > 3;
执行顺序:
from --> where --> select
查询 3 <= id <= 5 的数据:
select id,name from emp where id >= 3 and id <= 5;
select id,name from emp where id between 3 and 5;
查询 id < 3 或 id >5 的数据:
select id,name from emp where id not between 3 and 5;
查询薪资为10000或12000的数据:
select name,salary from emp where salary in (10000, 12000);
select name,salary from emp where salary = 12000 or salary = 10000;
查询薪资不为10000或12000的数据:
select name,salary from emp where salary not in (10000, 12000);
查询员工姓名中包含字母i的数据:
select id,name from emp where name like '%i%';
查询姓名由3个字符组成的数据:
select id,name from emp where name like '___';
select id,name from emp where char_length(name) = 3;
查询岗位描述为null的数据:
select id,name from emp where post_comment is null;