またはanti join
を使用する
select t1.color, t1.id
from
tableA t1
left outer join
tableA t2 on t2.id = t1.id and t2.color != t1.color
where
t1.color in ('red', 'blue')
and t2.color is null
またはanti join
を使用する
select t1.color, t1.id
from
tableA t1
left outer join
tableA t2 on t2.id = t1.id and t2.color != t1.color
where
t1.color in ('red', 'blue')
and t2.color is null