Anil Thakur

Anil Thakur

  • 566
  • 1.8k
  • 1.2m

How to get MemberId, MemberName,FriendId and FriendName?

Nov 7 2016 1:11 AM
 How i can get from these tables the list of Member and his friend name and friend id?
 
I need the four column output-:
1) MemberId
2) MemberName,
3) FriendId
4) FriendName 
  1. create table #temp(Memberid int,Name varchar(500))  
  2. Insert into #temp(Memberid,Name)values(1,'Anil Thakur')  
  3. Insert into #temp(Memberid,Name)values(2,'Ankit')  
  4. Insert into #temp(Memberid,Name)values(3,'Sonia')  
  5. Insert into #temp(Memberid,Name)values(4,'Airi')  
  6.   
  7. Create table #temp1(id int,SenderIdId int,ReceiverId int, status varchar(2))  
  8. insert into #temp1(id,SenderIdId,ReceiverId,status)values(1,1,2,'A')  
  9. insert into #temp1(id,SenderIdId,ReceiverId,status)values(2,2,4,'A')  
  10. insert into #temp1(id,SenderIdId,ReceiverId,status)values(3,3,1,'A')  
  11. insert into #temp1(id,SenderIdId,ReceiverId,status)values(4,4,1,'A')  
  12. insert into #temp1(id,SenderIdId,ReceiverId,status)values(4,4,2,'A')  


Answers (1)