gpt4 book ai didi

MySQL 找不到列

转载 作者:行者123 更新时间:2023-11-29 08:23:31 27 4
gpt4 key购买 nike

您好,他的查询给了我以下错误:

“on 子句”中存在未知列“m.home_team_id”

SELECT DISTINCT (
`m`.`match_id`),
`m`.`competition_id`,
`m`.`date`,
`h`.`team_name` AS "homeTeam", `h`.`team_id` AS "homeTeamID",
`a`.`team_name` AS "awayTeam", `a`.`team_id` AS "awayTeamID",
`o`.`for`, `o`.`against`
FROM `single` bs, `matches` m, `teams` t, `outcomes` o
JOIN `teams` `h` ON `m`.`home_team_id`=`h`.`team_id`
JOIN `teams` `a` ON `m`.`away_team_id`=`a`.`team_id`
WHERE `bs`.`match_id`=`m`.`match_id`
AND `m`.`score_id`=`o`.`outcome_id`
AND `actual_return` IS NOT NULL`enter code here`

m 是名为 matches 的表的别名,该表具有列 home_team_idaway_team_id 所以我不明白为什么该列不能'找不到吗?

艾伦。

最佳答案

SELECT 
DISTINCT (`m`.`match_id`),
`m`.`competition_id`,
`m`.`date`,

`h`.`team_name` AS "homeTeam",
`h`.`team_id` AS "homeTeamID",

`a`.`team_name` AS "awayTeam",
`a`.`team_id` AS "awayTeamID",

`o`.`for`,
`o`.`against`

FROM `single` bs

join `matches` m ON bs.match_id = m.match_id
join `outcomes` o m.score_id = o.outcome_id
join `teams` t --<--- I don't know what the join is for `teams` here
--- you probably don't need this in the query at all

JOIN `teams` `h` ON `m`.`home_team_id`=`h`.`team_id`
JOIN `teams` `a` ON `m`.`away_team_id`=`a`.`team_id`

WHERE `actual_return` IS NOT NULL

关于MySQL 找不到列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18617625/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com