Hello,
i have the following table structure table "location" has - id - parentLocation_id (relation to itself) - name
let assume we have the following data:
id  parentLocation_id  name
1         null           Egypt
2          1             Cairo
3          2             Zamalek
here we have three levels of locations , i want to get all levels (locations) that have id =1 or child of location_id.
The result must have all the three locations if i selected Egypt location (get all inheritance level).
i tried the following
select l.id from Location as l where l.id = 1 or l.id in (select id from Location where parentLocation_id= l.id);
here the result is not correct , and here i reached to the second level only.
How can i do this??
Thanks In Advance