0

I need to join Account (type = person account) --> Junction Object --> Account (type = business account)

We have person accounts enabled on our org. I can easily write what I need in SQL, but writing it in SOQL has proven difficult. Can you assist in writing a SOQL statement that pulls fields from person/customer account and business account?

SELECT * FROM Account as customerAccount JOIN Junction__c ON Junction__c.customerID__c = customerAccount.ID JOIN Account as businessAccount ON businessAccount.ID = Junction__c.businessID__c

0

I figured out how to use the relationship fields to do what I need.

Object CustomerCompanyRelationship__c has two custom fields, CustomerAccount__c and CompanyAccount__c, both lookups to the Account object.

Select CustomerAccount__r.ID, CustomerAccount__r.Name CompanyAccount__r.ID, CompanyAccount__r.Name from CustomerCompanyRelationship__c

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.