Search code examples
apisalesforcesoql

Salesforce SOQL return all partners of single account


I am trying to find all the account that have the same partner. I am new to SOQL and I cannot do a join so I am at a loss. Here is the closest I have gotten:

Select Name, Site, Status__c
FROM Account 
WHERE Account.Id = Partner.AccountToId 
AND Partner.AccountFromId = '0013000000bF5rtABC'

This does not work. Perhaps my brain is not functioning, but I just cant figure this out. I need to pull all of the account who are partners with '0013000000bF5rtABC' (or whatever account).


Solution

  • Below query will return all accounts who are partners with 0013000000bF5rtABC. In salesforce you need to use concept of inner queries to perform join.

    Select Name, Site, Status__c
    FROM Account 
    where ID IN 
    (Select AccountToId from Partner where AccountFromId = '0013000000bF5rtABC')