2

update我在使用和inner join使用 MYSQL 时遇到问题。

我需要使用另一个表连接属性。

我的查询:

update cfc_registration
 set teams = concat(r.teams, " - ", u.firstname, " ", u.lastname)
 from cfc_registration as r
 inner join cfc_user as u
 on r.cfcUserId = u.id
 where r.cfcTournamentId = 5

错误信息 :

 #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from cfc_registration as r inner join cfc_user as u on r.cfcUserId = u.id whe' at line 3
4

2 回答 2

2

不确定FROMINNER JOIN可以在更新查询中使用。试试这个:

update cfc_registration r, cfc_user u
set teams = concat(r.teams, " - ", u.firstname, " ", u.lastname)
where r.cfcTournamentId = 5 and r.cfcUserId = u.id
于 2019-02-02T17:21:18.113 回答
1

尝试这个

UPDATE cfc_registration as r
inner join cfc_user as u
on r.cfcUserId = u.id
and r.cfcTournamentId = 5 set teams = concat(r.teams, " - ", u.firstname, " ",    u.lastname)
于 2019-02-02T17:58:44.550 回答