gpt4 book ai didi

php - MySql 查询显示错误

转载 作者:行者123 更新时间:2023-11-29 07:55:33 25 4
gpt4 key购买 nike

我的查询显示错误“on 子句”中的未知列“u.id”

我的查询

SELECT u.id,u.username ,sum(s.score) AS User_Score 
FROM
`user` AS u ,
`team_member` as tm
LEFT JOIN score s ON (s.user_id=u.id and s.game_id=49 and s.team_id=27)
where tm.user_id=u.id and tm.team_id=27

最佳答案

您的加入不正确:

SELECT u.id,u.username ,sum(s.score) AS User_Score 
FROM
`user` AS u join `team_member` as tm on tm.user_id=u.id

LEFT JOIN score s ON (s.user_id=u.id and s.game_id=49 and s.team_id=27)
where tm.team_id=27
group by u.id,u.username

如果使用join,则必须对所有表使用它,并且不能与where语句混合使用。

关于php - MySql 查询显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25242378/

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