[英]Update table using another table and INNER JOIN
我在使用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
不确定FROM
和INNER 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
尝试这个
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.