Mysql的条件查询
按条件运算符筛选:> < != <> >= <=
按逻辑表达式筛选:and or not
模糊查询:
like
select * from student where name like ‘%a%’
sql查询语句中like不能查出null字段的数据,有时候会发现少数据。
通配符:
%任意多个字符,包含0个字符
_任意单个字符
escape 指定一个符号为转义字符,也可以直接用 “\”
案例:
select name from student where name like “_#_%” escape “#”;
between and(包含and两边的临界值)
in
含义:判断某字段的值是否属于in列表中的某一项
案例:
select name,group from student where group IN(‘1’,‘2’,‘3’);
is null
=或<>不能用于判断null值