In MySQL my table1
is
ID name parent
1 one 0
2 two 1
3 three 1
and my table2
is
ID name parent
1 com 2,3 -->is table1.ID
I want to relate between table2.parent
and table1.id
and show tree result :
com -> one -> two,three
How can I query it? I query this:
SELECT *
from table1 a
left join table1 b on b.parent=a.ID
where b.ID in (2,3)
this work nice but didn't work this:
SELECT *
from table1 a
left join table1 b on b.parent=a.ID
where b.ID in (select parent from table2)