This is my two table. first table save user info and 2 table save friendrequest.
Below sql query mutual friend display id correctly.
how to display mutual friend name using this query.
create table tbluserinfo(id int identity(1,1),First_Name varchar(100))
create table tblfrequst(f_id int identity(1,1),to_id int, from_id int)
insert into tbluserinfo values(10,shivani)
insert into tbluserinfo values(5,Mohit)
insert into tbluserinfo values(6,sanjay)
insert into tbluserinfo values(9,raman)
insert into tbluserinfo values(12,mohitgarg)
insert into tbluserinfo values(19,kartik)
insert into tblfrequst values(5,10)
insert into tblfrequst values(10,19)
insert into tblfrequst values(9,10)
insert into tblfrequst values(10,6)
insert into tblfrequst values(5,9)
insert into tblfrequst values(6,9)
insert into tblfrequst values(12,10)
(SELECT to_id AS user_id FROM tblfrequst WHERE from_id =5
UNION
SELECT from_id AS user_id FROM tblfrequst WHERE to_id = 5)
Intersect
(SELECT to_id AS user_id FROM tblfrequst WHERE from_id = 19
UNION
SELECT from_id AS user_id FROM tblfrequst WHERE to_id = 19)