. SQL Server. , , - . , XML Table-Valued-Parameter ( SQL Server 2008) @variable #temp. , .
, . : , , - . , , , , - , , .
, , , , . - . :
select ...
from Products p
where p.IsEnabled = 1
and exists (
select 1
from ProductCategories pc
join
where pc.ProductID = p.ProductID);
, , (ProductID, CategoryID) (CategoryID, ProductID) ( - , - NC). btw. , , . , :
with distinctProducts as (
select distinct pc.ProductID
from ProductCategories pc
join
select p.*
from Products p
join distinctProducts dc on p.ProductID = dc.ProductID;
, . , ( 99% ), .