我尝试将史蒂夫改为大卫所有的史蒂夫必须更改为大卫我有一个回合10000记录如果选择不同的surba我有1251所以我尝试使用这个sql语句立即更改它们:
UPDATE memba2
SET t1.surba = t2.surba
FROM memba2 t1
INNER JOIN memba t2 ON t1.id = t2.id
这是我得到的错误。请帮忙。
#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 memba2 t1 INNER JOIN memba t2 ON t1.id=t2.id' at line 1
答案 0 :(得分:0)
UPDATE语句中的INNER JOIN
稍有不正确,
你可以尝试: -
UPDATE memba2, memba
SET memba.surba=memba2.surba
WHERE memba.id=memba2.id;
如果你想要use INNER JOIN
,
正确的语法是: -
UPDATE memba2 INNER JOIN memba
SET memba.surba=memba2.surba
WHERE memba.id=memba2.id;
OR
UPDATE memba2 INNER JOIN memba ON (memba.id=memba.id)
SET memba.surba=memba2.surba
WHERE memba.id=memba2.id;
答案 1 :(得分:0)
update memba a join (select min(id) as id,surba from memba group by surba) b on b.surba = a.surba join memba2 c on c.id = b.id
set a.surba = c.surba