我正在尝试使用左联接来桥接两个表并强制索引仅存在于联接表上的索引,但出现以下错误:
您的SQL语法有误。检查手册
对应于您的MySQL服务器版本以使用正确的语法
'FORCE INDEX(l.sfdcId)WHERE l.sfdcId ='003A000001eR0HsIAK'附近
第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
知道为什么这会失败吗?
最佳答案
FORCE INDEX
在表定义之后:
SELECT a.activityDate,a.primaryAttributeValue,a.attributeDescription,
l.firstName,l.lastName,l.title,l .email
FROM activities a LEFT JOIN
leads l FORCE INDEX (sfdcId)
ON a.leadId = l.leadId
WHERE l.sfdcId = '003A000001eR0HsIAK'
ORDER BY a.activityDate DESC ;