The table is the following:
|child | parent|
|John | |
|Ivan | Ralph |
|Kat | Ivan |
I need to retrieve by a child name a child-parent entry and a parent-grandparent entry.
e.g. by Kat the result should be:
|Ivan | Ralph |
|Kat | Ivan |
Tried using this query:
SELECT * FROM people AS c1
LEFT JOIN people AS c2 ON c2.child = c1.parent WHERE c1.child = 'Kat'
But it returns a result as a single row.
|child | parent| child | parent|
|Kat | Ivan | Ivan | Ralph |
How I should compose a query so that it will return entires in a new row?