Sample for 8274855

0

Please login or register to vote for this query.

(click on this box to dismiss)

Enter Query Description

Stack Overflow

Q&A for programmers

-- Enter Query Title
-- Enter Query Description

DECLARE @approvals table (id int, user_id varchar(10), to_user_id varchar(10))
INSERT INTO 
@approvals
VALUES ( 1 , 'Matt' , 'Jessica' ),
( 2 , 'Jessica' , 'Matt' ),
( 3 , 'Eeyore' , 'Jessica' ),
( 4 , 'Eeyore' , 'Matt' )

SELECT * 
FROM @approvals A 
INNER JOIN @approvals B 
ON A.user_id = B.to_user_id 
and B.user_id = A.to_user_id
WHERE A.to_user_id = 'Matt'

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached