"查询钱大于100小于200的所有xx信息": betweenand中100和200不能颠倒,xx之间默认小的在前面,大的在后面
select*from 表
where 钱>100and 钱<200;select*from 表
where 钱 between100and200;"查询钱不大于100小于200的所有信息":加个notselect*from 表
where 钱 notbetween100and200;
in:类似于or或,格式是:in(?,?,?..);
# 括号中字段类型要一样的;in里边不能使用通配符,通配符要加like才可以使用,in中不能加like"查询钱是100或200或300的员工"; 类型是varchar的要加''select 员工
from 表
where 钱=100or 钱=200or 钱=300;select 员工
from 表
where 钱 in(100,200,300);
is null/is not null:为null/不为null
# 是不是null不能使用 = 或 != null判断,= <>可以判断0,不能判断null# 可以使用<=>判断null:<=>:安全等于"查询奖金为null的所有数据":
select*from 表
where 奖金 isnull;select*from 表
where 奖金 <=>null;"查询奖金不为null的所有数据"select*from 表
where 奖金 isnotnull;
MySQL -> DQL:条件查询之模糊查询:like;between and;in;is null
like:像# % 表示随便多少个字符;# _ 表示一个字符;# \ 转义字符;加了\就不表示原来的意思,如n是字符n,\n变成换行;假设$是代表钱,\$代表字符$,不再表示钱;select * from 表 where name字段 like '%罗%';"第二个字符为德的所有数据": _代替第一个字符;同理有 ___A%:这里有3个_,代表第四个字符是A的数据select * from 表 where name字段 like '_德%';"字段中间有_的数据(特殊字符)":例如