简体   繁体   English

两张表Salesforce SOQL查询

[英]Two table Salesforce SOQL query

I'm new to Salesforce and was given a query to write between two tables. 我是Salesforce的新手,并获得了要在两个表之间编写的查询。 I need your help. 我需要你的帮助。 There are two objects Task(fields - Task TID, Task Name) and Task Hier(Task TID, Task Name and Project ID). 有两个对象Task(字段-任务TID,任务名称)和Task Hier(任务TID,任务名称和项目ID)。

How to get all the Project IDs using SOQL when the user selects the Task Name in VF page, from that name get the Task TID of Task Object and then go to Task Hier table matching Task TID and get all the Project IDs matching the Task ID and display. 当用户在VF页面中选择“任务名称”时,如何使用SOQL获取所有项目ID,从该名称中获取任务对象的任务TID,然后转到与任务TID匹配的“任务层”表,并获得与任务ID匹配的所有项目ID。和显示。

I'm not that good at SQL. 我不太擅长SQL。 Any help in this matter is really appreciated. 对此表示任何帮助,我们深表感谢。

Thanks Chaitra 谢谢柴特拉

From your description in your question, it would appear that you already have all the required fields on the "Task Hier" object and don't need to join to the Task object. 从对问题的描述中,您似乎已经在“ Task Hier”对象上具有所有必填字段,并且不需要加入Task对象。

  1. Task Name for the SOQL where clause SOQL where子句的Task Name
  2. Task TID 任务TID
  3. Project ID 专案编号

If this isn't the case, can you expand the question out with the API names of the fields and objects required? 如果不是这种情况,您可以使用所需字段和对象的API名称扩展问题吗? The custom objects and fields will have API names ending with __c. 自定义对象和字段的API名称以__c结尾。

To get the task id you would use something like this: task__c.Id because your task object is a custom Id then it uses __c at the end however the Id is a standard field therefore it does not need __c. 要获得任务ID,您可以使用以下命令:task__c.Id,因为您的任务对象是自定义ID,然后在末尾使用__c,但是Id是标准字段,因此不需要__c。 also you can use force.com Explorer to see the output of executed SOQL queries before using them in your system. 您也可以使用force.com Explorer在系统中使用它们之前查看已执行的SOQL查询的输出。 https://developer.salesforce.com/page/ForceExplorer https://developer.salesforce.com/page/ForceExplorer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM