SELECT * FROM students FORCE INDEX (score) WHERE class_id = 1 ORDER BY id DESC;
报错ERROR 1176 (42000): Key 'score' doesn't exist in table 'students'
注意是索引的名字,建议创建索引时名字要起好,不要和列重名,推荐idx_score这样的名字
列score存在,索引idx_score还不存在,需要先添加索引
ALTER TABLE students ADD INDEX idx_score (score);
好问题 好回答哦
Sign in to make a reply
石年618
SELECT * FROM students FORCE INDEX (score) WHERE class_id = 1 ORDER BY id DESC;
报错ERROR 1176 (42000): Key 'score' doesn't exist in table 'students'