Reputation: 49
My query is this and php is:
Select *
from games
left join players on games.id = players.id
echo "game:" . $player . ",pass" . $pass...
I know its not correct php echo just faster writing
Output:
game:ost1232,pass:10,desc:Difficulty:Highest,players:Duiski,lad:0region:3;game:ost1232,pass:10,desc:Difficulty:Highest,players:testarn,lad:0,region:3;
but I want
game:ost1232,pass:10,desc:Difficulty:Highest,players:Duiski.testarn,lad:0,region:3;
The code outputs two games result but just want to input the players in the query with a dot in between.
Games
table: id, game, password, description, ladder, region.Players
: id, playerI want to check players that join the game
Upvotes: 0
Views: 43
Reputation: 9432
I am guessing that you should have an intermediate table if a user plays more games, so I would have these tables:
games
id
name
players
id
name
player_games
game_id
user_id
I would get the games of the user 'John' like this:
select
players.name as player_name,
games.name as game_name
from games
join player_games on player_games.game_id
join players on player_games.user_id = players.id
where players.name='John'
Optional: Add a Unique key constraint on player_games
Upvotes: 1