So I have a generalised table called beneficiaries which gives the specialised table parent and child. So parent and child table reference a beneficiary id. However, child table references a parent beneficiary id. Now my struggle is I want to write a query which returns the name of the child from the beneficiary and the name of the parent from the beneficiary while showing which parent a child belongs to. I wrote this query:
select * from beneficiaries
inner join child on beneficiaries.bene_id = child.ParentBene_id
inner join parent on beneficiaries.bene_id = parent.parentBene_id;
But the results I get is just the parent name and the id for the child. Structure of Tables