How to JOIN a table with itself while using a sub-query? I JOIN a table to itself as

SELECT t1.TagID AS TagID1
    ,t2.TagID AS TagID2
    ,COUNT(1)
FROM TagMap AS t1
JOIN TagMap AS t2 ON t1.ArticleID = t2.ArticleID AND t1.TagID &lt;&gt; t2.TagID
GROUP BY t1.TagID, t2.TagID


How can I limit the rows retrieved for each table (t1 and t2) by

WHERE TagID IN(SELECT TagID FROM Tags WHERE Articles&gt;50)


Note that the table TagMap is huge with over 200M rows, and I wish to limit its size before JOIN.

In fact, the reason I want to limit the number of rows of TagMap is that the table is too big and I cannot perform the JOIN.
You use a subselect query as basis for t1 and t2

Like

SELECT 
    t1.TagID AS TagID1, t2.TagID AS TagID2, COUNT(1)
FROM
    (SELECT 
        *
    FROM
        TagMap
    WHERE
        TagID IN (SELECT 
                TagID
            FROM
                Tags
            WHERE
                Articles &gt; 50)) AS t1
        JOIN
    (SELECT 
        *
    FROM
        TagMap
    WHERE
        TagID IN (SELECT 
                TagID
            FROM
                Tags
            WHERE
                Articles &gt; 50)) AS t2 ON t1.ArticleID = t2.ArticleID
        AND t1.TagID &lt;&gt; t2.TagID
GROUP BY t1.TagID , t2.TagID