11月11日

DQL

模糊查询通配符

符号 (-) 代表一个

例子: select*from Table_2 where name like’_’;
符号(%)赖子

例子:select*from Table_2 where name like ‘%白%’;
符号(【内容a,内容b】)字符集

例子:select*from 表名 where 列名 like ‘[孙,李]%’;
符号(【^内容c,内容d】)字符集取反

在介绍反向模糊查询之前先说一下,模糊查询:

SELECT * FROM table as t WHERE t.userName LIKE ‘%张三%’; (userName是table表的字段)

这个是一般的模糊查询的模板,而反向模糊查询的模板跟模糊查询的模板非常相似,只是相应的位置改变一下就行了。

反向模糊查询:

SELECT * FROM table as t WHERE “张三的偶像” LIKE t.userName; (查询的结果可以是:张三%,这个反向模糊结果是格式上的相同)。

范围查找
between…and
格式:列名 between 最小值 and 最大值

select * from goods where name like ‘%小米%’ and name like ‘%手机%’ and price between 1399 and 2000;
… and …
格式:列名>=最小值 and 列名<=最大值

例子:select * from goods where name like ‘%小米%’ and name like ‘%手机%’ and price >=1000 and price <= 2000;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值