General information
Forum:
Microsoft SQL Server
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only