在一个查询中检索Contact.Email,Opportunity.Name和OpportunityLineItem.Quantity

时间:2014-01-07 16:44:12

标签: salesforce soql

我正在尝试在单个SOQL查询中检索Contact.Email,Opportunity.Name和OpportunityLineItem.Quantity。这可能吗?如果是这样,怎么样?

我的查询是:

Select Opportunity.Id, Opportunity.Name, Contact.Email, (Select Quantity From OpportunityLineItem) From OpportunityContactRole Limit 10

我的主要目标是在单个查询中获取OpportunityContactRole和OpportunityLineItem中的元素。

2 个答案:

答案 0 :(得分:3)

你很亲密:)

SELECT Id, Name,
    (SELECT Quantity FROM OpportunityLineItems),
    (SELECT Contact.Email FROM OpportunityContactRoles)
FROM Opportunity

答案 1 :(得分:0)

您可以尝试以下内容:

SELECT Opportunity.Name, Contact.Email, Contact.Id FROM OpportunityContactRole WHERE Opportunity.Id = '<OppId>'LIMIT 1