Salesforce:SOQL - 热门文章标题

时间:2013-06-20 08:23:27

标签: join salesforce soql knowledge-management

文章标题出现在KnowledgeArticleVersion表中,而ViewArtized Score出现在KnowledgeArticleViewStat表中。两个表的父级是KnowledgeArticle,但我无法将其加入KnowledgeArticleVersion,因为DB模式中不存在关系名称。因为,我可以先执行这样的查询

Select k.ParentId, k.NormalizedScore From KnowledgeArticleViewStat k order by k.NormalizedScore 

然后

SELECT Title, UrlName, KnowledgeArticleId FROM KnowledgeArticleVersion WHERE PublishStatus='Online' AND language ='en_US' and KnowledgeArticleId in (:ids)

但是我的宗教禁止我执行两个查询而不是一个查询。

也许有人可以告诉我在SOQL中执行连接的正确方法。

1 个答案:

答案 0 :(得分:0)

假设你使用k.parentIds:ids,这将起作用:

SELECT id,Title , UrlName, KnowledgeArticleId, PublishStatus, language 
FROM KnowledgeArticleVersion 
WHERE PublishStatus='Online'
AND language ='en_US' 
AND KnowledgeArticleId  IN (SELECT ParentId
                            FROM KnowledgeArticleViewStat
                           )