我目前有一个匹配结果表
+----------+----------+--------+-----------+--------+-----------+-----------+-----------+
| hometeam | awayteam | p1home | p2home... | p1away | p2away... | homescore | awayscore |
+----------+----------+--------+-----------+--------+-----------+-----------+-----------+
我用相当笨重的东西查询
SELECT
(SELECT COUNT(hometeam)
FROM fixture_data
WHERE (p1home = '$playerID' OR p2home = '$playerID' OR...)
AND hometeam = '$teamname')
+
(SELECT COUNT(awayteam)
FROM fixture_data
WHERE (p1home = '$playerID' OR p2home = '$playerID' OR...)
AND awayteam= '$teamname')
AS matches_played
获取特定球员 $playerID 为特定球队参加的比赛数 $teamname
桌上玩家很简单
+----------+-----------+-----------+
| playerID | firstname | surname |
+----------+-----------+-----------+
打电话后的那一刻
SELECT * FROM players
我通过 PHP 为每个玩家调用初始查询,因为我正在努力将这两个查询连接到一个单独的 MYSQL 查询中以生成一个表
+----------+-----------+-----------+----------------+
| playerID | firstname | surname | matches_played |
+----------+-----------+-----------+----------------+
这可能吗?还是我当前使用 PHP 的解决方案会尽可能高效?