我有大约 20 张牌桌的玩家数据库。我正在尝试找出特定球员的首秀(首场比赛出场)。该数据库有两个单独的表,用于“外观”和“替换”。最初,我设法分别正确地获取了我的查询,也就是说,我设法在一个查询中获取了第一次出现的详细信息,并在另一个查询中获取了替换的详细信息。我已经尝试了几种程序将两个查询合并为一个,但是每次我尝试时,都会发生一些错误。是的,我也做了很多谷歌搜索。以下是单独的程序:
显示球员的完整首秀详情。
SELECT DATE( MatchDateTime ) , tplss_opponents.OpponentName, CONCAT(MatchGoals,"-", MatchGoalsOpponent), PlayerLastName
FROM tplss_matches
JOIN tplss_opponents ON tplss_matches.MatchOpponent = tplss_opponents.opponentID
JOIN tplss_appearances ON tplss_matches.MatchID = tplss_appearances.AppearanceMatchID
JOIN tplss_players ON tplss_appearances.AppearancePlayerID= tplss_players.PlayerID
WHERE `PlayerLastName` = "Leo Messi"
ORDER BY `MatchDateTime` ASC
LIMIT 1;
显示球员处子秀细节包括换人。
SELECT DATE( MatchDateTime ) , tplss_opponents.OpponentName, CONCAT(MatchGoals,"-", MatchGoalsOpponent), PlayerLastName
FROM tplss_matches
JOIN tplss_opponents ON tplss_matches.MatchOpponent = tplss_opponents.opponentID
JOIN tplss_substitutions ON tplss_matches.MatchID = tplss_substitutions.SubstitutionMatchID
JOIN tplss_players ON tplss_substitutions.SubstitutionPlayerIDIn= tplss_players.PlayerID
WHERE `PlayerLastName` = "Leo Messi"
ORDER BY `MatchDateTime` ASC
LIMIT 1;
我的目标是找到一名球员在比赛中的第一条记录,无论是作为首发球员还是替补球员,以较早者为准。这通常被称为“首次亮相”。
查询输出示例:
日期 OpponentName 结果 PlayerLastName
2005-08-17 匈牙利 2-1 Lionel MESSI
感谢任何帮助或指导。