You are here: Re: NOT EXISTS using single table? « MsSQL Server « IT news, forums, messages
Re: NOT EXISTS using single table?

Posted by Plamen Ratchev on 01/22/08 20:47

As David's solution requires SQL Server 2005, here is one for SQL Server
2000:

SELECT DISTINCT item
FROM ItemLoc AS I1
WHERE NOT EXISTS (SELECT *
FROM ItemLoc AS I2
WHERE I2.loc = 'OH'
AND I2.item = I1.item)

Since your item column does not allow NULLs, you can also write:

SELECT DISTINCT item
FROM ItemLoc
WHERE item NOT IN (SELECT item
FROM ItemLoc
WHERE loc = 'OH')

HTH,

Plamen Ratchev
http://www.SQLStudio.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация