zoukankan      html  css  js  c++  java
  • MySql like 查询 变向写法(不用like 完成like查询)

    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等开头的数据。

  • 作者:hoojo
    出处:
    blog:http://blog.csdn.net/IBM_hoojo
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

版权所有,转载请注明出处 本文出自:
分享道版权所有,欢迎转载,转载请注明出处,谢谢
收藏
关注
评论
查看全文
  • 相关阅读:
    第八场 hdu 6136 Death Podracing(dfs+思维)
    第九场 hdu 6162 Ch’s gift(树链剖分+线段树)
    树链剖分 模板
    CodeForces
    第十场 hdu 6172 Array Challenge(矩阵快速幂)
    第十场 hdu 6171 Admiral(双向bfs找交点)
    CodeForces
    第十场 hdu 6178 (bfs)
    第十场 hdu 6180 Schedule (multiset)/(思维)
    第八场 hdu 6143 Killer Names(思维题)
  • 原文地址:https://www.cnblogs.com/hoojo/p/2226676.html
  • Copyright © 2011-2022 走看看