Soql query to get all related contacts of an account in an opportunity

Posted by Prady on Stack Overflow See other posts from Stack Overflow or by Prady
Published on 2012-03-22T11:26:11Z Indexed on 2012/03/22 11:29 UTC
Read the original article Hit count: 277

Filed under:
|

i have SOQL query which queries for some records based on a where condition.

select id, name,account.name ... <other fields> from opportunity where eventname__c='Test Event'

i also need to get the related contact details for the account in the opportunity. ie i need to add the email ids of contact who all are part of the account in the opportunity.

For each opportunity, i need to get all the contacts emailids who are associated with the account in opportunity.

I cant really figure out how to approach this. referring the documentation i can get the contact info of a account using the query

SELECT Name,
(
SELECT LastName
FROM Contacts
)
FROM Account

How can i use this along with opportunity?

Thanks

© Stack Overflow or respective owner

Related posts about salesforce

Related posts about soql