Salesforce soql inner join

Select Name,SRID__c,Sales_Team__r.Sales_Group__c from Account
WHERE Business_Unit_Code__c = ‘334’ AND Sales_Team__c != ”

SOQL Joins

Let’s look at what we can do with this data with some familiar JOIN patterns borrowed from SQL. This time however, we will utilize them in SOQL and also use the power of relationship traversal in path expressions that allow us to do joins implicitly.

In each case below, we will use the pattern with respect to a query problem that we would like to express with SOQL. For Position, we will use Position__c, for Application we will use Job_Application__c, and for Candidate we will use Candidate__c in the corresponding code snippets.

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

Results:

Image:RightOuterJoin.jpg

wiki.developerforce.com/page/A_Deeper_look_at_SOQL_and_Relationship_Queries_on_Force.com

Print Friendly, PDF & Email
This entry was posted in Administration, Development and tagged , . Bookmark the permalink.