Isn't this what you want ? ?declare @Products table( ProductID int, ProductName varchar(10), TagID int)insert into @Productsselect 1001, 'A', 1 union allselect 1002, 'B', 1 union allselect 1003, 'C', 1 union allselect 1004, 'D', 1 union allselect 1005, 'E', 2 union allselect 1006, 'F', 2 union allselect 1007, 'G', 2 union allselect 1008, 'H', 2declare @SalesChild table( InvNo int, ProductID int)insert into @SalesChildselect 5001, 1001 union allselect 5001, 1004 union allselect 5002, 1007-- Harsh's querySelect p.*from @Products p LEFT JOIN @SalesChild sc on p.ProductID = sc.ProductIDwhere sc.ProductID is NULLand p.TagID = 1/* RESULT as per your specificationProductID ProductName TagID ----------- ----------- ----------- 1002 B 11003 C 1*/-- Harsh's querySelect p.*from @Products p LEFT JOIN @SalesChild sc on p.ProductID = sc.ProductIDwhere sc.ProductID is NULLand p.TagID = 2/* RESULT as per your specificationProductID ProductName TagID ----------- ----------- ----------- 1005 E 21006 F 21008 H 2*/
KH