Where did we meet?


Please login or register to vote for this query.

(click on this box to dismiss)

Motor Vehicle Maintenance and Repair Meta

Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

-- This query displays the questions where the two users meet.
-- It accepts two paramaters: 
--     @AskerID     => the who raised the question
--     @AnswererID  => the one who answered
-- It also display whether the answer has been accepted or not.

-- All users are ALLOWED to fork this query for improvements.

DECLARE @AskerID int = ##AskerId##
DECLARE @AnswererID int = ##AnswererID##
SELECT    a.CreationDate as [DateAsked], 
          a.Title AS [Question],
          c.Body AS [Answer], 
          CASE WHEN a.AcceptedAnswerID = c.ID THEN 'Accepted' ELSE '' END [Status]
FROM      Posts a
          INNER JOIN PostTypes b
            ON a.PostTypeId = b.ID AND b.ID = 1
          INNER JOIN
            SELECT    aa.ParentId, aa.Body, aa.OwnerUserId, aa.ID
            FROM      Posts aa
                      INNER JOIN PostTypes bb
                        ON aa.PostTypeId = bb.ID AND bb.ID = 2
            WHERE     aa.OwnerUserId = @AnswererID
          ) c ON a.ID = c.ParentId
WHERE     a.OwnerUserId = @AskerID
ORDER BY  a.CreationDate ASC

Enter Parameters

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