日期:2014-05-16  浏览次数:21058 次

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
可能高点