2

I have two queries, how can I join both together into one SOQL?

SELECT o.Partner_Account__c, o.id, o.name, o.Account.Id,  from Opportunity o
SELECT a.id, a.name from account a where a.id = my_Partner_Account__c

Partner_Account__C is id of Account object, I want to get PartnerAccount id/name in the opportunity query.

Opportunity object has two Account objects, one is a relation o.Account and the other is lookup - o.Partner_Account__C.

Thanks

1

1 Answer 1

2

If you have introduced a new Lookup relation from Opportunity to Account as Partner_Account__c, first check the relation API name by generating a WSDL (Settings > Develop > API > Generate WSDL). Then use below code(it's assuming the relation as Partner_Account__r )

SELECT o.Id, o.Name, o.AccountId, o.Partner_Account__r.Id, o.Partner_Account__r.Name FROM Opportunity o

Partner_Account__r.Id, Partner_Account__r.Name are giving you the Partner Account Id, Name respectively

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .