0
我试图用一个左连接弥合两个表,并迫使索引只存在于连接表的索引,但我得到了以下错误:单力指数抛出错误的连接表
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FORCE INDEX (l.sfdcId) WHERE l.sfdcId = '003A000001eR0HsIAK' ORDER BY a.activity' at line 3
这里的查询正在运行的输出(如果我删除了FORCE INDEX正常工作):
SELECT a.activityDate,a.primaryAttributeValue,a.attributeDescription,l.firstName,l.lastName,l.title,l.email
FROM activities AS a LEFT JOIN
leads AS l
ON a.leadId = l.leadId FORCE INDEX (l.sfdcId)
WHERE l.sfdcId = '003A000001eR0HsIAK'
ORDER BY a.activityDate DESC
任何想法,为什么会失败?
https://dev.mysql.com/doc/refman/5.7/en/index-hints.html - *“这在语法上是有效的省略index_list用于USE INDEX,意思是“不使用索引”,省略FORCE INDEX或IGNORE INDEX的index_list是一个语法错误。“* --- *”FORCE INDEX提示像USE INDEX(index_list)一样行为,假设表扫描非常昂贵,换句话说,只有在无法使用其中一个命名索引来查找表中的行时才使用表扫描。“* –