我无法让两个INNER JOINS工作。当我只使用第一个INNER JOIN时显示数据但是当我添加第二个INNER JOIN时没有显示任何内容。
以下是我正在使用的网址代码: website.com/matchdetails/season/match_id
<?php
$db = new PDO('mysql:host=db.xx.xx;dbname=xx','xx','xx');
$sth = $db->prepare("
SELECT *
FROM
matchdetails AS md
INNER JOIN
players AS p
ON
(p.player_id = md.player_id)
INNER JOIN
matches AS m
ON
(m.match_id = md.match_id)
WHERE (CONCAT_WS('/', season, match_id)) = :season");
$sth->execute(array(':season' => substr($_SERVER['PATH_INFO'], 1)));
foreach($sth as $row) {?>
<?php echo 'Name '. $row['name'] . '<br/>'; ?>
<?php echo 'Goals ', $row['goals'] . '<br/>'; ?>
<?php echo 'Assists ',$row['assists'] . '<br/>'; ?>
<?php echo 'VVO Score ',$row['vvo_score'] . '<br/>' . '<br/>'; ?>
<?php }?>
我的数据库结构是:
表匹配
表格匹配详情
桌面玩家
答案 0 :(得分:2)
在ON (p.player_id = m.player_id)
中,m表是'匹配',而'匹配'没有名称为'player_id'的列。