How to perform a select using a WHERE NOT EXISTS

Posted by Peter Bridger on Stack Overflow See other posts from Stack Overflow or by Peter Bridger
Published on 2010-05-26T09:52:58Z Indexed on 2010/05/26 10:11 UTC
Read the original article Hit count: 203

Filed under:
|

I'm using LINQ2SQL and I want to compare two tables and select all rows that are missing from one tables (based upon one of the column values).

In standard SQL I would write this as:

SELECT 
FirstName,
LastName,
RefId,
Email
FROM
Users_ActiveDirectory AS ADU
WHERE
NOT EXISTS
(
SELECT 
U.RefId
FROM
Users AS U
WHERE
U.RefID = ADU.RefId
)

However I'm not sure how to achieve the same result using LINQ2SQL?

© Stack Overflow or respective owner

Related posts about sql

Related posts about linq-to-sql