Search code examples
salesforcesoql

SOQL query :Salesforce


Suppose we have three objects

account(id,name)
opportunity(id,amount,stage)
properties(id,address)

account object has one to many relationship to opportunity object and opportunity object has one to many relationship to properties object .

And we want SOQL query to display only name ,stage and address

id,name,amount,stage,address are fields in the objects.


Solution

  • Using the "dot" notation you can do joins between tables. Something like this will work:

    SELECT Address__c,
        Opportunity__r.StageName,
        Opportunity__r.Account.Name
    FROM Property__c
    

    It's quite basic stuff so looks like you have some reading to do. Check http://www.salesforce.com/us/developer/docs/dbcom_soql_sosl/Content/sforce_api_calls_soql_relationships.htm for a start.

    And please tag questions with relevant stuff, this has nothing to do with Service Cloud or Chatter.