SELECT PARENT_ID
FROM rel
GROUP BY PARENT_ID
HAVING SUM(PROP_ID NOT IN (5,1)) = 0
AND SUM(PROP_ID = 1) = 1
AND SUM(PROP_ID = 5) = 1
SELECT PARENT_ID
FROM rel
GROUP BY PARENT_ID
HAVING SUM(PROP_ID NOT IN (5,1)) = 0
AND SUM(PROP_ID = 1) = 1
AND SUM(PROP_ID = 5) = 1