I have a table named 'role'
id | parent_id | name
---+-----------+--------------------
1 | NULL | Machine
2 | 3 | Ram
3 | 4 | Cpu
4 | NULL | Computer
5 | NULL | Electronic Device
I need a (mysql or postgress sql) query which will give the possible parents of a particular role.
For example
the possible parent roles of 'Computer' are
id | name
---+-------------------
5 | Electronic Device
1 | Machine
please help me