select t.* from teacher as t
join center as c on t.center_id = c.id
where t.center_id not in
(select distinct t2.center_id from user as u
join teacher t2 on u.id = t2.id
where u.auth = 'DIRECTOR');
select distinct t2.center_id
from user as u
join teacher t2 on u.id = t2.id
where u.auth = 'DIRECTOR';
select distinct c.id
from teacher as t
join center as c on t.center_id = c.id;
select t.* from teacher t
where t.center_id not in
(select distinct t2.center_id
from user as u
join teacher t2 on u.id = t2.id
where u.auth = 'DIRECTOR' and t2.center_id is not null);
레퍼런스
https://aljjabaegi.tistory.com/459 [알짜배기 프로그래머:티스토리]