具有自联接 + 关系的 Salesforce SOQL 查询(ContentDocument/ContentVersion)

标签 salesforce soql force.com

我正在尝试编写 SOQL 查询来检索一些 Salesforce Content 记录,但在确定下一步时遇到了一些困难。如果该文档的任何版本的自定义字段具有值(不为空),我想排除该文档的所有版本。这是我正在尝试做的事情的简化版本:

Select  Id, Title
From    ContentVersion
Where   ContentDocumentId Not In
        (
           Select ContentDocumentId,
           From   ContentVersion
           Where  Custom_Field__c != null
        )

所以我知道你不能编写一个子查询来定位与其外部查询相同的对象,所以显然我上面指定的内容是行不通的。关于什么可行的任何建议?

谢谢。

最佳答案

你能尝试这样的事情吗:

Select C.Id from ContentDocument C where 
    ID not in ( Select ContentDocumentId
        From   ContentVersion
        where Custom_Field__c != null)

关于具有自联接 + 关系的 Salesforce SOQL 查询(ContentDocument/ContentVersion),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8933165/

相关文章:

Salesforce - 连接对象是否可以被引用为具有主从关系的其他对象的父对象?

python - simple_salesforce python 中的父子关系查询,从有序字典中提取

SQL 到 SOQL 转换 (Salesforce.com SOQL)

python - 试图了解 OAuth2 refresh_token 流程 - 不断获得 invalid_grant

parsing - 为编程语言编写代码格式化工具

salesforce - Visualforce:如何使用 $User 显示用户帐户

multidimensional-array - 在 Salesforce 中优化 Levenshtein 距离算法

extjs - 从 JSON 加载 ExtJS TreeStore

python - SalesforceObject.search/get 不能一起工作? Python/简单-salesforce

Salesforce 相当于 "SELECT DISTINCT"?