MySQL5.7对sql语句强制使用索引查询时报错如下:
解决:这里的id字段是表的主键,查看别人的经验贴得知是语法错误,参考链接https://*.com/questions/19205004/key-emp-no-doesnt-exist-in-table-employees ,当强制索引是主键时sql语句应这样写
mysql> SELECT COUNT(UA.id) AS tp_count FROM ck_user_audit UA RIGHT JOIN ck_user AS U force index(PRIMARY) ON U.id = UA.uid LIMIT 1;