Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
EXISTS
Message
From
08/02/2001 10:39:00
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
EXISTS
Miscellaneous
Thread ID:
00473986
Message ID:
00473986
Views:
48
What is the difference between the two following Selects. It seems that they should return the same results, but the "NOT IN" produces 0 records and the EXISTS clause produces multiple rows. I thought that they should return the same result.

Using "NOT EXISTS":
SELECT DISTINCT u1.[vcRequestor]
FROM dbPDRProductionCopy..tbl_PDR u1
WHERE NOT EXISTS
(SELECT u2.[TolasKey]
FROM Core..User_tbl u2
WHERE u1.[vcRequestor] = u2.[TolasKey])

Using "NOT IN":

SELECT DISTINCT u1.[vcRequestor]
FROM dbPDRProductionCopy..tbl_PDR u1
WHERE u1.[vcRequestor] NOT IN
(SELECT u2.[TolasKey]
FROM Core..User_tbl u2)
Next
Reply
Map
View

Click here to load this message in the networking platform