Given a Relation Person(id,name,momid,dadid)
Return all siblings (ie those with common momid,dadid)
eg 1,2
So in this query i need to result all siblings in a row, with one pair of siblings per row.
I have the solution not very sure if it works..it is
select p1.id,p2.id
from person p1,person p2
where p1.momid=p2.momid
and p1.dadid=p2.dadid
I believe it is the write solution but it resulted a row 1,1 so is the query logic wrong ?
Both p1 and p2 can be the same person in your query since you’re not saying they should be different. You can just add that condition and it should work just fine;