Duplicate Chains

0

Please login or register to vote for this query.

(click on this box to dismiss)

Lists duplicates of duplicates of duplicates of duplicates. Probably most of the results are duplicate loops.

Stack Overflow

Q&A for professional and enthusiast programmers

WITH Duplicated AS
(
    SELECT
        p.Id AS Id,
        d.Id AS DuplicateId
    
    FROM
        Posts d,
        Posts p,
        PostLinks pl
    WHERE
        pl.LinkTypeId = 3
        AND pl.PostId = d.Id
        AND pl.RelatedPostId = p.Id
),

DoubleDuplicated AS
(
    SELECT
        p.Id AS Id,
        d.DuplicateId AS DuplicateId
    
    FROM
        Duplicated d,
        Posts p,
        PostLinks pl
    WHERE
        pl.LinkTypeId = 3
        AND pl.PostId = d.Id
        AND pl.RelatedPostId = p.Id
),

TripleDuplicated AS
(
    SELECT
        p.Id AS Id,
        d.DuplicateId AS DuplicateId
    
    FROM
        DoubleDuplicated d,
        Posts p,
        PostLinks pl
    WHERE
        pl.LinkTypeId = 3
        AND pl.PostId = d.Id
        AND pl.RelatedPostId = p.Id
),

QuadrupleDuplicated AS
(
    SELECT
        p.Id AS Id,
        d.DuplicateId AS DuplicateId
    
    FROM
        DoubleDuplicated d,
        Posts p,
        PostLinks pl
    WHERE
        pl.LinkTypeId = 3
        AND pl.PostId = d.Id
        AND pl.RelatedPostId = p.Id
)

SELECT
    d.DuplicateId AS [Post Link]

FROM
    TripleDuplicated d,
    Posts p,
    PostLinks pl

WHERE
    pl.LinkTypeId = 3
    AND pl.PostId = d.Id
    AND pl.RelatedPostId = p.Id

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results