MySql like 查询 变向写法(不用like 完成like查询)
2011-10-27 15:59
337 查看
select * from account where userName like 'ad%'; select * from account where userName >= 'ad' and userName < 'ae' /* 这两种查询的结果是一样的,效率好像也差不多,没有做具体的效率测试,有兴趣可以测试下效率。 like查询中的ad%是查询ad开头userName的数据, 而userName >= 'ad'就是查询ad开头的数据并且还包含 ae、af、ag……,也就是说是查询“ad”中包含d且大于“ad”中d的数据 所以,and userName < 'ad'就保证查询的区间在“ad”中的,而ae、af、ag……这些数据就不会出现在结果集中。 当然你可以试试: select * from account where userName >= 'ad' and userName < 'az'; 结果集是不是包含:ae、af、ag……ak、al……ay、az等开头的数据。 */
相关文章推荐
- MySql like 查询 变向写法(不用like 完成like查询)
- MySql like 查询 变向写法(不用like 完成like查询)
- Mysql模糊查询like效率,以及更高效的写法 在使用msyql进行模糊查询的时候,很自然的会用到like语句,通常情况下,在数据量小的时候,不容易看出查询的效率,但在数据量达到百万级,千万级的时
- Mysql模糊查询like效率,以及更高效的写法
- python mysql like查询的写法
- Mysql模糊查询like效率,以及更高效的写法
- Mysql模糊查询like效率,以及更高效的写法
- MySQL左联多表查询where条件写法示例
- Mybatis中oracle、mysql、db2、sql server的like模糊查询
- CI 下 mysql 查询语句的写法--心得
- sql 语句用substr 不用 like 可以提升查询效率
- iBatis 中 Like 的写法实现模糊查询
- MySql模糊查询like通配符与使用正则查询详细介绍
- mysql查询一个表的数据插入另一个表的写法
- mysql预编译模糊查询(like)中?的冲突,出错的解决办法。
- 查询所有订单的最新信息的SQL语句的写法 DISTINCT配合count和group by一起完成
- mysql查询排名的方法(yii的写法)
- MySql的join(连接)查询 (三表 left join 写法)
- python的mysql模块使用like查询
- MYSQL Like查询不区分大小写