Discussion in 'SQL Server 2005 General Developer Questions' started by skd, Dec 5, 2007.
Hi,Wanted to know if I can use some join or a better way
The NOT EXISTS subqueries are correct.
You might get better performance with LEFT JOINs and NULL criteria, but it all depends on the actual data - so you need to compare both versions:
SELECT DISTINCT parid FROM pardat
LEFT JOIN dweldat ON dweldat.parid = pardat.parid
LEFT JOIN comdat ON comdat.parid = pardat.parid
WHERE dweldat.parid IS NULL AND comdat.parid IS NULL
By the way - why the quotes around the identifier names? That is rather old-fashioned.
Looks like the original post has been edited and some important fragments been removed.
Separate names with a comma.