I have two tables:
userdata
guidUser username
-----------------
12 plr1
13 plr2
14 plr3
15 plr4
games
id guidUser1 guidUser2
-------------------------
1 12 13
2 15 14
I want to select names of players from the same userdata table based on their guid.
The result I'm trying to obtain is:
id guidUser1 username guidUser2 username2
--------------------------------------------
1 12 plr1 13 plr2
2 15 plr4 14 plr3
If the value was only one I could do
SELECT g.id, g.guidUser1, u.username, g.guidUser2 from games g, userdata u WHERE g.guidUser1=u.guidUser1
But how I can obtain the second username 'username2'?
