I have a Object called 'Vehicle', and I have lookup field for the Object called "Unitorder" in Vechicle. In unitorder i have a lookup field for the Object called "carset" In carset I have related list object called "service".

I want to take the Service records.

Am able to take upto carset.


[Select name,UnitOrder__r.Carset__r.name from Vechicle]

How to take the related service records for Carset in a single query ?

Carset is master and service is child object.

  • Say the Relationship in manner of "What is Parent and What are Childs"? Your description is confusing. Don't tell the Names of the lookup fields. Just say what are your parent and child objects and From which object you want to query from?
    – Subhash
    Commented Jun 10, 2016 at 5:22

1 Answer 1


You need to form two separate SOQL queries for that. One to query Carset and service child records, like below

      (SELECT Name FROM Service__r)
FROM Carset 

and other one same as you have mentioned in your question. You can use both of them to form a map or wrapper class to achieve what you have mentioned. I don't think you can achieve this task using a single soql.

Check out this blog to get a basic understanding of Parent-child and Child-parent SOQL.

  • There is no relation ship between Vechicle and carset
    – uma451
    Commented Jun 10, 2016 at 5:20
  • Do you want to query both Vehicle and Service in single query?
    – Mahmood
    Commented Jun 10, 2016 at 5:24
  • Yes.There is no relationship between vechicle and carset. to obtain carset from vechicle am going via "unitorder" .Now i want to get related list of service from carset in "single query"
    – uma451
    Commented Jun 10, 2016 at 5:26
  • I want to get the service from vechicle
    – uma451
    Commented Jun 10, 2016 at 5:37
  • What is the relationship b/w Service and Vehicle, I can't derive any relationship b/w them, from your question or comments.
    – Mahmood
    Commented Jun 10, 2016 at 5:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .