数据库模糊查询

(1)like 一般与通配符进行搭配使用

通配符 %任意多个字符,包含0个字符 。 _任意单个字符

#查询员工名中包含字符a的员工信息

select * from 表名 where 列名 like '%a%';

#查询员工名中第三个字符a的员工信息

select * from 表名 where 列名 like '__a%';

escape后指定转义字符

select * from 表名 where 列名 like '_$_%' escape $;

(2)between      and     包含临界值

临界值不能颠倒顺序

#查询员工编号为100到200之间的员工信息

select * from 表名 where id>=100 and id<=200;

>= <=

select * from 表名 where id between 100 and 200;

(3) in              in 相当于 =

in列表的值类型必须一致或兼容

#查询编号为1和2 的员工信息

select * from 表名 where id in(1,2);

(4)is null / is not null

#查询没有奖金的员工名

select name from 表名 where 奖金 is null;

#查询没有奖金的员工名

select name from 表名 where 奖金 is not null;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值