Hello,
I starting to teach myself SQL, bought some books and its going good thusfar.
But some things don't work as I thought they would ;-(
I have 2 tables (MySQL):
1. Games with (amongst others) player1 and player2 in which field are the id's of the player from the players table
2. The player table with id, name, adres, etc
What I want is a query that gives me the names of the players instead of the id's.
I tried this:
SELECT `ronde` , `games`.`player1` , `players`.`name` , `games`.`player2` , `players`.`naam`
FROM `games` , `players`
WHERE `seizoen` = "2005/06"
AND `games`.`player1` = `players`.`id`
UNION SELECT `ronde` , `games`.`player1` , `players`.`naam` , `player2` , `players`.`naam`
FROM `games` , `players`
WHERE `seizoen` = "2005/06"
AND `games`.`player2` = `players`.`id`
ORDER BY 1
I do get the 2 names but always the player1's name
Any help would of course greatly be appreciated
Bauke (from Holland so English is not my native language ;-))
I starting to teach myself SQL, bought some books and its going good thusfar.
But some things don't work as I thought they would ;-(
I have 2 tables (MySQL):
1. Games with (amongst others) player1 and player2 in which field are the id's of the player from the players table
2. The player table with id, name, adres, etc
What I want is a query that gives me the names of the players instead of the id's.
I tried this:
SELECT `ronde` , `games`.`player1` , `players`.`name` , `games`.`player2` , `players`.`naam`
FROM `games` , `players`
WHERE `seizoen` = "2005/06"
AND `games`.`player1` = `players`.`id`
UNION SELECT `ronde` , `games`.`player1` , `players`.`naam` , `player2` , `players`.`naam`
FROM `games` , `players`
WHERE `seizoen` = "2005/06"
AND `games`.`player2` = `players`.`id`
ORDER BY 1
I do get the 2 names but always the player1's name
Any help would of course greatly be appreciated
Bauke (from Holland so English is not my native language ;-))