Relationships in Salesforce
Relationships in Salesforce :- In our previous Salesforce Developer Tutorial we have learned many topic regarding Salesforce Object Query Language(SOQL). In this Salesforce Developer Training Tutorial we are going to learn about SOQL inner join and SOQL Outer Join Relationships in Salesforce.
Inner and Outer Join Relationships in Salesforce.
Earlier in our Salesforce Tutorial we have learned about Different Relationships in Salesforce. Although Salesforce Object Query Language does not support or allow arbitrary joints but it supports some features to control related objects in Salesforce.
In this SOQL Salesforce Tutorial we learn about some additional SOQL features. Some of he additional features are.
- Inner Join and Outer Join.
- Semi Join and Anti-Join.
- Multi Select pick lists.
Inner Join Relationships in Salesforce.
In SOQL statements, Inner and Outer Joins are used to join related objects like parent object and child objects to retrieve all related fields from base objects including the records of non refer related object.
let us see an example :-
- SELECT NAME, ACCOUNT__r.NAME FROM PROJ__C.
From above SOQL statement, we are trying to retrieve Name and Account name from Project object(custom object). Here the parent object is Account object and child object is project and the relation between two objects is Look up Relationship. __r keyword is added to custom objects for relationships in Salesforce.
SOQL statement consists of single base object and it is specified using the keyword called “FROM”. Here we using Force.com IDE’s schema explorer to run SOQL statements. Above shown statement is Outer join statement. Outer joins does not retrieve test project values because it does not match to any row in the account object tables.
SOQL Inner joins Relationships in Salesforce.
SOQL Inner Join statements are used to eliminate the records which records are not matched with related objects. In SOQL inner join statements we use filtering condition as shown below.
Example :- SELECT NAME, ACCOUNT__r.NAME FROM PROJ__C WHERE ACCOUNT_c !=NULL.
From above screenshot we observe that the unmatched records are eliminated by filtering condition. Form this article we have successfully learned about SOQL Inner Join, Outer Join Relationships in Salesforce. In our next SOQL tutorial we learn about Semi Join and Anti Join Relationships in Salesforce.