create table myTest( a int, b int, c int, KEY a(a,b,c) );
select * from myTest where a=3 and b=5 and c=4; ---- abc顺序
select * from myTest where c=4 and b=6 and a=3;
select * from myTest where a=3 and c=7;
select * from myTest where a=3 and b>7 and c=3; ---- b范围值,断点,阻塞了c的索引
select * from myTest where b=3 and c=4; --- 联合索引必须按照顺序使用,并且需要全部使用
select * from myTest where a>4 and b=7 and c=9;
select * from myTest where a=3 order by b;
select * from myTest where a=3 order by c;
select * from mytable where b=3 order by a;
SELECT * from staffs where name='2000'; -- 因为mysql会在底层对其进行隐式的类型转换 SELECT * from staffs where name=2000; --- 未使用索引