I have to make query to select data like parent is SFI
with id 1
then remove bath , hack off and break up are SFI
's child and shower tray , timber floor , screeded are break up's child.
Structure of table. (SOR table)
sor_id | items | parent_id
-------------------------
1 | SFI | 0
2 | Remove bath | 1
3 | Hack off | 1
4 | break up | 1
5 | Shower tray | 4
6 | Timber floor| 4
7 | screeded | 4
8 | general 123 | 1
So my question is can we use self joins two times and some workout in php loops for achieveing this result?
To be frank I don't know that can we manage this hierarchy with one parent_id,
select * from sor as m_sor
LEFT JOIN sor as c_sor ON m_sor.sor_id = c_sor.parent_id
LEFT JOIN sor as sc_sor 0N sc_sor.sor_id = c_sor.parent_id