+ Start a Discussion
Ramesh Naidu PRamesh Naidu P 

How to write Outer Join Quries in SOQL ?

How to write Outer Join Quries in SOQL ?
Always ThinkinAlways Thinkin
Ideally the outer joins are between two tables that have some relationship, even if it's just a shared parent relationship. If you must do an arbitrary join between two tables that have no relationship at all, we're forced to revert to building collections of both tables in Apex and then iterating over that map of one to join values from the other. This article, https://developer.salesforce.com/page/A_Deeper_look_at_SOQL_and_Relationship_Queries_on_Force.com, describes the means of left- and right-outer joins where a relationship already exists.
Amit Chaudhary 8Amit Chaudhary 8
Please check below post. I hope that will help u

SOQL Joins

Right Outer Join
Problem: Find job Applications and related Departments (from Applications).
Note that for this example, we would like to list applications including those which are not related to a Position yet. This is accomplished by an outer join.
SOQL Query:
SELECT Name, Position__r.Department__c FROM Job_Application__c
Left Outer Join
Problem: Find all positions with their related list of applications.
Again, we would like to list the positions regardless of whether there is a related application or not.
SOQL Query
SELECT Name, (SELECT Name FROM Job_Applications__r) FROM Position__c
Please let us know if this will help you