我的查询是这个,php是:
Select *
from games
left join players on games.id = players.id
echo "game:" . $player . ",pass" . $pass...
我知道它不正确的php echo只是写得更快
输出:
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;
但我想要
game:ost1232,pass:10,desc:Difficulty:Highest,players:Duiski.testarn,lad:0,region:3;
代码输出两个游戏结果,但只想输入查询中的玩家,中间有一个点。
Games
表:id,游戏,密码,描述,阶梯,区域。Players
:id,player 我想查看加入游戏的玩家
答案 0 :(得分:1)
如果用户玩更多游戏,我猜你应该有一个中间表,所以我会有这些表:
games
id
name
players
id
name
player_games
game_id
user_id
我会得到用户的游戏' John'像这样:
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'
可选:在player_games
上添加唯一键约束