I have three tables, table1 store records which may have next level ID(child), table2 lists corresponding child ID, and table3 stores the possible message for that particular ID.
table1:
------------------------------------------
ID | group | tochild
------------------------------------------
1 A y
2 A n
3 B y
4 A y
5 A n
table2:
----------------------------
ID | childID |
----------------------------
1 3
1 2
3 5
4 2
table3:
--------------------------------
ID | message
--------------------------------
2 message for ID2
4 message for ID4
5 message for ID5
Now I want to populate message for selected ID (both current level and sub level if exist), for example, if "ID=1", how to display the following list? how to select table recursively for sub-level?
-----------------------------------
ID | message
-----------------------------------
2 message for ID2
5 message for ID5