奇怪的 Salesforce.com SOQL 关系语法

发布于 2024-11-19 01:19:02 字数 271 浏览 6 评论 0原文

我正在查看一个 SOQL 查询,该查询可能已经严重过时,或者使用其神奇的 field__r.foreign_table 连接语法的某些方面,代码包含对

USER_JOBS__R

的引用目前,当前对象上不存在类似的字段,但存在名为 USERJOBS 的表,其中 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谎言月老 2024-11-26 01:19:02

首先,查看关系查询的文档 ,它将拥有您需要的一切。

由于表USER_JOBS__R 是复数且以__R 结尾,因此它可能会进行父子查询。 USER_JOBS__R 称为“子关系名称”,在创建查找字段时创建。如果您找到定义子对父关系的查找,您可以通过查看字段定义来确认这一点(请注意,__R 将不会出现,因为只有 API 才需要)。一般来说,如果您进行查找,例如从申请人到名称为 JOB__C 的职位,则子关系名称将采用复数形式,并将 __C 替换为 __R 为您提供JOB__R。这只是默认值,您可以为子关系名称选择任何您想要的名称。知道这一点后,您可以执行以下查询来为您提供所有申请人以及每项工作:

[select id, (select id from APPLICANTS__R) from JOB__C]

对于您的场景,我假设有一些“工作”对象可以查找用户对象,可能是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 is JOB__C, the child relationship name will be a pluralized and __C replaced with __R to give you JOB__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:

[select id, (select id from APPLICANTS__R) from JOB__C]

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 of USER_JOBS__R.

比忠 2024-11-26 01:19:02

您所指的通常称为关系字段(以“__r”结尾的字段)

The one that you are referring is generally called relationship fields (the fields ending in “__r”)

茶底世界 2024-11-26 01:19:02

这是用于查询查找(父子)关系中的字段的语法。

This is the syntax for querying fields in a lookup (parent-child) relationship.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文