我在SQL上有这个代码,我试图在Salesforce中使用它。我收到一个错误,它无法识别JOIN功能。
以下是代码:
SELECT
lu_table.Name,
lu_table.id,
primary.Start_date,
primary.end_date,
secondary.metric
FROM primary
LEFT JOIN secondary
ON primary.xyz= secondary.xyz
LEFT JOIN lu_table
ON primary.id = lu_table.id
group by lu_table.Name;
答案 0 :(得分:3)
Salesforce拥有名为SOQL的查询语言。该语言没有JOIN
功能。这是reference
SOQL语法:
SELECT fieldList [subquery][...]
[TYPEOF typeOfField whenExpression[...] elseExpression END][...]
FROM objectType[,...]
[USING SCOPE filterScope]
[WHERE conditionExpression]
[WITH [DATA CATEGORY] filteringExpression]
[GROUP BY {fieldGroupByList|ROLLUP (fieldSubtotalGroupByList)|CUBE (fieldSubtotalGroupByList)}
[HAVING havingConditionExpression] ]
[ORDER BY fieldOrderByList {ASC|DESC} [NULLS {FIRST|LAST}] ]
[LIMIT numberOfRowsToReturn]
[OFFSET numberOfRowsToSkip]
[FOR {VIEW | REFERENCE}[,...] ]
[ UPDATE {TRACKING|VIEWSTAT}[,...] ]
修改强>
你在SOQL中查询就是这样的。
SELECT
Start_date,
end_date,
(SELECT Id, Name FROM lu_table),
(SELECT metric FROM secondary)
FROM primary
WHERE xyz IN (SELECT xyz FROM secondary WHERE condition)
AND Id IN (SELECT id FROM lu_table WHERE condition)
GROUP BY lu_table.Name;
但我不确定这种形式的查询是否会达到SF限制