SQL腳本
CREATE TABLE `test1` (
`id` int(11) NOT NULL,
`a` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`b` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`c` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
KEY `i1` (`a`,`b`,`c`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
測試sql:
desc select * from test1 where a='1' and b='1' and c='1'; //走索引
desc select * from test1 where a='1' and b='1'; //走索引
desc select * from test1 where a='1' and c='1'; //走索引
desc select * from test1 where b='1' and c='1'; //沒走索引
實際測試結果:bc沒有走索引
參考資料: