Reciprocal accepting of answers for user questions

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

with questions as (
select
   p1.owneruserid as question_userid
 , p2.owneruserid as answer_userid
 , p1.id -- to view sample ids
from posts p1
inner join posts p2 on -- to fetch answer post
  p1.acceptedanswerid = p2.id
)
select top 5 
    -- distinct -- unique pairs (may throw timeout with distinct and no top)
    q1.question_userid as userid1
  , q1.answer_userid as userid2
  , q1.id, q2.id -- to view sample ids
from questions q1
inner join questions q2 on
      q1.question_userid = q2.answer_userid -- accepted answer from someone
  and q1.answer_userid = q2.question_userid -- who also accepted our answer
  and q1.question_userid <> q1.answer_userid -- and we aren't self-accepting

Enter Parameters

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