【发布时间】:2019-02-02 16:54:33
【问题描述】:
我在 MYSQL 中使用 update 和 inner join 时遇到问题。
我需要使用另一个表来连接属性。
我的查询:
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
【问题讨论】:
-
先试一试-> ..
SET r.teams = concat(r.teams, u.firstname, u.lastname) as ConcatString -
使用
set r. teams = concat(r.teams, " - ", u.firstname, " ", u.lastname) as ConcatString,我收到相同的错误消息。 -
好吧,先简单试试,不用 concat ->..
set r.teams = u.firstname.. 如果可行,那么试试不带双引号的 concat。 -
“更新自”..?
标签: mysql sql inner-join