A simple method is aggregation and having
:
select id
from colors c
where color in ('RED', 'PINK')
group by id
having count(*) = 2;
This assumes that your original data has no duplicates. If that is the case, use count(distinct color) = 2
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…