DECLARE @ProductFeature TABLE (ProductID int, FeatureID int)
INSERT INTO @ProductFeature
SELECT 1,100
UNION ALL
SELECT 1,101
UNION ALL
SELECT 1,102
UNION ALL
SELECT 2,103
UNION ALL
SELECT 2,104
UNION ALL
SELECT 3,100
UNION ALL
SELECT 3,101
UNION ALL
SELECT 3,102
UNION ALL
SELECT 4,102
UNION ALL
SELECT 4,101
UNION ALL
SELECT 5,110
UNION ALL
SELECT 5,100
UNION ALL
SELECT 5,101
My requirement is if I pass ProductID = 1, then I have to select Product with features similiar to ProductID = 1.
Since ProductID = 1 has 3 features(100,101,102), there is only ProductID = 3 which has same count and features which has ProductID = 1
Expected result
ProductID FeatureID
3 100
3 101
3 102