2020-11-11

模糊查询:

1. 通配符查询:

- _ 代表一个
例子:select * from Table_2 where name like ‘__’;

- % 赖子
例子:select * from Table_2 where name like ‘%白%’;

- [内容a,内容b] 字符集
例子:select * from 表名 where 列名 like ‘[孙,李]%’;

- [^内容a,内容b] 字符集取反
例子:select * from 表名 where 列名 like ‘[^孙,李]%’;

2.范围查询:

- 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;

你可能感兴趣的:(数据库,sql)