'not in'에 해당되는 글 1건

  1. 2011.02.02 NOT IN 속도가 느릴때 LEFT JOIN 이용하는방법. SQL
MySQL에서 특정 항목들을 제외시키고자할때 주로 사용하는 명령어가 NOT IN 입니다. 하지만 속도가 만족스럽지 못할때가 있습니다. 이때는 LEFT JOIN명령어를 사용해보세요.

예를 들어,
select * from cdr where calldate not in (
select calldate from cdr 
where disposition = 'ANSWERED')

의 경우는
다음과 같이 바꿀 수 있습니다.
select t1.calldate from cdr as t1 
left join (
select calldate from cdr 
where disposition = 'ANSWERED') as t2 
on t1.calldate=t2.calldate 
where t2.calldate is null 



Posted by leeyongwan
,