I have a hierarchy of organizations in organization_table. In this table I've data like,
--------------------------------------------------------------
organization_id | organisation_type | organization_parent_id |
-------------------------------------------------------------- Sample
101 | Primary | 101 | 101
102 | Secondary | 101 | |
103 | Secondary | 102 | 102
104 | Primary | 104 | |
105 | Secondary | 104 | 103
106 | Secondary | 105 |
Here 101 is a primary parent for 101,102 and 103 same as 104 is primary parent for 104, 105 and 106. So by query I need to find Primary parent for record_id 103 and 106.
I'm weak at recursive query execution so please help me out to a suitable way with this.
Thanks in Advance.!