[SalesForce] Lookup Relationship – traversal level

I would like to know till what level can a lookup relation ship fields can be traversed.
For master detail , I could find 3 levels .

I tried this , but didn't work.

select id , Lookup1__r.Lookup2__r.Status__c 
  from CustomObject__c where Accountid='001L000000q9MfQ'

Best Answer

Understanding Relationship Query Limitations

In each specified relationship, no more than five levels can be specified in a child-to-parent relationship. For example, Contact.Account.Owner.FirstName (three levels).

5 level is the limit for child to parent

In each specified relationship, only one level of parent-to-child relationship can be specified in a query. For example, if the FROM clause specifies Account, the SELECT clause can specify only the Contact or other objects at that level. It could not specify a child object of Contact.

Related Topic