• This problem is known as Relational Divsion[/url].

    There is the exact division (only 3 and 6) and the one with a remainder (at least 3 and 6). Yours seems to be the second one.

    DECLARE @C TABLE (

    [Category] int NOT NULL PRIMARY KEY

    );

    INSERT INTO @C ([Category]) VALUES (3), (6);

    SELECT

    PC.Project

    FROM

    [dbo].[Project_Category] AS PC

    INNER JOIN

    @C AS C

    ON PC.Category = C.Category

    GROUP BY

    PC.Project

    HAVING

    COUNT(DISTINCT PC.Category) = (SELECT COUNT(*) FROM @C);

    GO

    Notice that I am constraining the categories I am looking for to be unique (primary key in this case).

    This is not the only way of solving relational division neither the one with best performance.