SELECT c.PostId AS AnswerId, STUFF(( SELECT ' | ' + c2.Text

0

Please login or register to vote for this query.

(click on this box to dismiss)

Drones and Model Aircraft Meta

Q&A for experienced flyers, pilots, and builders of drones and model aircraft

SELECT 
    c.PostId AS AnswerId,
    STUFF((
        SELECT ' | ' + c2.Text
        FROM Comments c2
        WHERE c2.PostId = c.PostId
        ORDER BY c2.CreationDate
        FOR XML PATH(''), TYPE
    ).value('.', 'NVARCHAR(MAX)'), 1, 3, '') AS AllComments
FROM Comments c
JOIN Posts p ON c.PostId = p.Id
WHERE p.Id IN (12453584, 2988271)
  AND p.PostTypeId = 2 -- PostTypeId = 2 indicates answers
GROUP BY c.PostId
ORDER BY c.PostId;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results