Example of how to replace NOT IN clause with JOIN
/*NOT IN query*/
USE AdventureWorks;
GO
SELECT ProductID
FROM Production.Product
WHERE ProductID
NOT IN (
SELECT ProductID
FROM Production.WorkOrder);
/*JOIN Query*/:-
SELECT p.ProductID
FROM Production.Product p
LEFT JOIN Production.WorkOrder w ON p.ProductID = w.ProductID
WHERE w.ProductID IS NULL;



Subscribe to this blog
Briefcase
Print
Loading comments...