当前位置: 代码迷 >> Sql Server >> mysql中between and 再有or 以及大于小于查询数据,那个效率最高
  详细解决方案

mysql中between and 再有or 以及大于小于查询数据,那个效率最高

热度:24   发布时间:2016-04-24 18:26:07.0
mysql中between and 还有or 以及大于小于查询数据,那个效率最高?
数据库中有一张表,里面有一个int类型的字段,取值为1、2、3、4、5,下面三中查询语句那一种效率最高?
1.select * from table where colum between 2 and 4
2.select * from table where colum >= 2 and colum<= 4
3.select * from table where colum=2 or colum=3 or colum=4
4.select * from table where colum!=1 and colum!=5
------解决方案--------------------
取决于你的SQL有没有索引 还有索引正确与否

直接这样说是不科学的。
------解决方案--------------------
1.select * from table where colum between 2 and 4
2.select * from table where colum >= 2 and colum<= 4
可能高点
  相关解决方案