Skip to content
Advertisement

Two foreign keys referring to one primary key on SQL SERVER query select items

I’d to create a database that records transactions between two users. A user can transfer points (think of it as money) to another user. user table looks like:

And the transaction table should look like:

just i needed this result:

Could someone give hints to provide SQL Server code?

Select from_user, to_user, name, transfer_amount from transaction iner join users on trans.id==user.id;

Advertisement

Answer

Something like this, I guess

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement