Select Only if ID Value is X and no other value
05:50 08 Oct 2026

How do I select the ID's that have only the colour "red" and not other colour:

ID Colour
1 Red
3 Blue
2 Red
4 Red
1 Yellow

In am trying to write an SQL Where clause that gets me only ID's that have a value and no other value.

In this case I want a query that gives me only ID 4 & 2 because ID 1 has both Red and Yellow. I don't want to get number 1, just 4 & 2.

sql if-statement select where-clause