This is closely related to this question, but adds another requirement.
Given a parent table \'parent\'
╔════════════╦════════╗ ║ PARENT_ID ║ NAME
SELECT PARENT_ID FROM rel GROUP BY PARENT_ID HAVING COUNT(PROP_ID)=2 AND COUNT(DISTINCT case when PROP_ID IN ( 1, 5 ) then PROP_ID end)=2
This will select all PARENT_ID that have exactly two rows, with exactly two, non duplicated, PROP_ID that match.
PARENT_ID
PROP_ID