Skip to main content
2 of 2
added 37 characters in body
Matt Lacey
  • 25.8k
  • 7
  • 68
  • 153

Salesforce Object Query Language (SOQL) does not support JOIN operations that SQL does. The reason for this is the multi-tenant nature of the Force.com platform. https://developer.salesforce.com/page/Multi_Tenant_Architecture

SOQL does have a feature called Relationship Queries. https://www.salesforce.com/us/developer/docs/dbcom_soql_sosl/Content/sforce_api_calls_soql_relationships.htm

You can use Parent / Child Queries to save yourself SOQL calls and improve performance, however you cannot go more than 1 level down to Children and more than 5 levels up for Parents.

So you can do for example:

Select Id, Name,
    (Select Id, Name, Object_1__r.Name from Junctions_1__r),
    (Select Id, Name, Object_2__r.Name from Junctions_2__r),
    (Select Id, Name, Object_3__r.Name from Junctions_3__r)
from Main_Object__c

Which is letting you get the data in one query.

You will still need to use MAP's in APEX to JOIN data across the junctions.

I hope that helps you.

CoryCowgill
  • 2.2k
  • 1
  • 17
  • 20