I have a table structure as fallows :
id fnane parentid
1 abc null
2 xyz 1
3 mno 1
And need query all the team members by passing either parent id or child id. I have tried the fallowing query
SELECT
child.emailid, child.id
FROM
user parent
RIGHT JOIN
user child ON child.parentid = parent.id
WHERE
parent.parentid IS NULL
AND (parent.id = '452fa614-572e-4b79-bb3c-71eccc5b5547'
OR child.parentid = '452fa614-572e-4b79-bb3c-71eccc5b5547')
;
But not working in either of the fallowing cases.
case 1 : If i pass parentid
fetching only child rows.
case 2: If i pass id
(child record) 0 rows fetching.