sql - Select two records where a two way relationship exists -


i have user table contains user id , name.

i have likes table contains userid1 , userid2.

when user1 likes user2, ids entered in likes table respectively.

how can retrieve users both each other?

join likes table , select rows mutual likes:

    select *        likes like1  inner join likes like2 on like1.userid1 = like2.userid2                        , like1.userid2 = like2.userid1 

Comments

Popular posts from this blog

c - Calling a function within a loop -

How i fill combobox items in Radgridview manually using in vb.net -

vb.net - Unbound DataGridView add row with checkbox error -