讨论数量:
@轻描淡写 对 MySQL 5.7.19,Mariadb12,MySQL8.0.13 测试后都是这样。
CREATE TABLE `tbla` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`age` INT(11) NULL DEFAULT NULL,
`birth` TIMESTAMP NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
INDEX `indx_A_ageBirth` (`age`, `birth`)
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=4
;
//
desc select * from tbla where age > '20' order by 'created_at'
//
desc select * from tbla where age > '20' order by created_at
看看结果
使用 id order by,测试时,加上单引号后, 还能影响所使用的索引
推荐文章: