EXPLAIN select * from user where deptId=1;
1 SIMPLE user index age 41 106131 Using where; Using index
EXPLAIN select * from user where age=1;
1 SIMPLE user ref age age 5 const 1 Using index
ddl
CREATE TABLE user (id int(11) NOT NULL AUTO_INCREMENT,age int(11) DEFAULT NULL,deptId varchar(11) DEFAULT NULL,
PRIMARY KEY (id),
KEY age (age,deptId) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=105819 DEFAULT CHARSET=utf8;
和视频中的最左匹配原则对不上呢?,为什么单独用deptId查询时,还是能用到索引呢