Activity Forums Salesforce® Discussions How to perform inner query in SOQL (Salesforce Object Query Language)?

  • Subhendu

    Member
    January 12, 2018 at 12:27 pm

    Hi Ankit,

    You need the relationship name to perform inner SOQL query. For example, if you are going to perform a query to get Accounts along with their contacts then your query will be something like -

    Select Id, Name,(Select Id, LastName from Contacts) from Account.

    Where Contacts is the relationship name between Account and Contact.

     

    Hope this helps,

    Thanks,

    Subhendu

  • Rajan

    Member
    January 12, 2018 at 12:28 pm

    Hi Ankit ,

     

    Here is the example of inner SOQL query(parent to child ) -(Account and contact)

    [SELECT ID , Name, (SELECT id FROM Contacts ) FROM Account ]

     

     

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos