¾È±Ô °øºÎ¹æ

MS-SQL > Not in °ú Not exists

µî·ÏÀÏ : 2017-06-30 17:08 Á¶È¸¼ö : 33,755

Â÷ÁýÇÕ (except, minus) 
¾Æ½±Áö¸¸ ÀÌ·±ÇÔ¼ö´Â sql¿¡ ¾ø½À´Ï´Ù.
Analysis Services¿ëÀ¸·Î´Â ÀÖÁö¸¸ t-sqlÇÔ¼ö´Â ¾Æ´ÏÁö¿ä)
    
±×·³ ÀÌ·±°æ¿ì´Â ¾î¶»°Ô ÇÒ±î¿ä ? 
   -> not in À̳ª not exists ¸¦ ÀÌ¿ëÇϴ°̴ϴÙ. ¶Ç´Â outer joinÀ» »ç¿ëÇϴ°ÍÀÔ´Ï´Ù.  

1. not in »ç¿ë
    
select * from Å×À̺í¸í where Çʵå¸í not in ('aaa')
select * from Å×À̺í¸í where id not in (select id from Å×À̺í¸í)

2. not exists »ç¿ë

select * from Å×À̺í¸í where Çʵå¸í not exists ('aaa')
select * from Å×À̺í¸í where not exists(select * from Å×À̺í¸í y where y.id=x.id)

µµ¿òÀÌ µÇ¼Ì±æ ¹Ù¶ø´Ï´Ù.
¡Ø Ȥ½Ã µµ¿òÀÌ µÇ¼Ì´Ù¸é ´ñ±Û¿¡ ÇѸ¶µð ³²°ÜÁÖ¼¼¿ä!
ÀÛ¼ºÀÚ   ºñ¹Ð¹øÈ£
ÀÚµ¿±Û ¹æÁö     (ÀÚµ¿±Û ¹æÁö ±â´ÉÀÔ´Ï´Ù.)
³»¿ë   ´ñ±Û´Þ±â 
À̸ÞÀÏ ¹®ÀÇ : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.