like
#单引号必须有
select * from table where name like '%a_'
通配符
% :任意多个,包含0个
_ :任意一个
查询第二个字符为下划线的
select * from table where name like '_\_%'
\ 字符为转义字符,有些字符有特殊含义,加上\后使字符变为本来的字符
between and
#包含临界值
#两个临界值不能改顺序
select * from table where age between 0 and 120
<=>
select * from table where age >=0 and age <=120
in
#数据类型必须统一或者兼容
#in使用的是=,所以里面不能用通配符
select * from table where department in ('p1','p5','p2')
<=>
select * from table where department ='p1' or department ='p5' or department ='p2'
is null
#正确使用
select * from table where department is null
#错误示范
#判断是否为null不能直接使用=
select * from table where department = null
#错误示范
#is 只能和 null连用
select * from table where department is 12000
安全等于 <=>
#可以判断两者
#没啥缺点就是长得可读性差,因此就用的少了
select * from table where department <=> 12000
select * from table where department <=> null