Reputation: 25
I have a two tables:
usermaster
Id int pk, name varchar
monytranfer
TId int pk, sender int references usermaster (id), receiver int references usermaster(id), amount
How do I join these two tables to get the below columns?
TId, sendername, receivername, amount
Thanks.
Upvotes: 1
Views: 78
Reputation: 540
As per my understanding you monytranfer table has two columns which are referring to the same column of user master right. i have written the sql query for that.
Select
m.Tid, u1.name as SenderName, u2.name as ReceiverName, m.amount
from
monytranfer m
join
usermaster u1 on u1.id = m.sender
join
usermaster u2 on u2.id = m.receiver;
Is this what you want ? Inform me if it solves your problem.
Upvotes: 3