奇怪的 Salesforce.com SOQL 关系语法
我正在查看一个 SOQL 查询,该查询可能已经严重过时,或者使用其神奇的 field__r.foreign_table 连接语法的某些方面,代码包含对
USER_JOBS__R
的引用目前,当前对象上不存在类似的字段,但存在名为 USER 和 JOBS 的表,其中 JOBS 包含对 USER 的查找。
有人见过这是 SOQL 语法的一部分吗?
I'm looking at an SOQL query that may either be hideously out of date or using some facet of their magical field__r.foreign_table join syntax, the code contains a reference to
USER_JOBS__R
where nothing like that currently exists as a field on the current objects there are however tables called both USER and JOBS of which JOBS contains a lookup on USER.
Has anyone ever seen this as part of the SOQL syntax?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,查看关系查询的文档 ,它将拥有您需要的一切。
由于表
USER_JOBS__R
是复数且以__R
结尾,因此它可能会进行父子查询。USER_JOBS__R
称为“子关系名称”,在创建查找字段时创建。如果您找到定义子对父关系的查找,您可以通过查看字段定义来确认这一点(请注意,__R
将不会出现,因为只有 API 才需要)。一般来说,如果您进行查找,例如从申请人到名称为JOB__C
的职位,则子关系名称将采用复数形式,并将__C
替换为__R
为您提供JOB__R
。这只是默认值,您可以为子关系名称选择任何您想要的名称。知道这一点后,您可以执行以下查询来为您提供所有申请人以及每项工作:对于您的场景,我假设有一些“工作”对象可以查找用户对象,可能是
USER__C
,其子关系名称为USER_JOBS__R
。First off, take a look at docs for Relationship Queries, it'll have everything you need.
Because the table
USER_JOBS__R
is plural and ends in__R
it's likely going to parent to children query.USER_JOBS__R
is called the "Child Relationship Name" and is created when ever a lookup field is created. If you find the lookup that defines the child to parent relationship you can confirm this by looking at the field definition (note that the__R
will not be present as this is only needed with the API). In general if you have a lookup, say from an applicant to a job, whose name isJOB__C
, the child relationship name will be a pluralized and__C
replaced with__R
to give youJOB__R
. This is only the default, you can choose whatever you want for the child relationship name. Knowing this you could do the following query to give you all applicants along with each job:For your scenario I would assume there is some "Job" object that has a lookup to the User object, probably
USER__C
, that has a child relationship name ofUSER_JOBS__R
.您所指的通常称为关系字段(以“__r”结尾的字段)
The one that you are referring is generally called relationship fields (the fields ending in “__r”)
这是用于查询查找(父子)关系中的字段的语法。
This is the syntax for querying fields in a lookup (parent-child) relationship.