在临时表上更新我的联接

时间:2012-05-14 09:12:40

标签: mysql join

我有一个名为leaderboard的表

我创建

 create temporary table leaderboard 
 (
     rank integer primary key auto_increment, 
     score_id integer, 
     game varchar(65), 
     user_id integer
)

select 
     id, 
     highscore, 
     playername 
from 
     players 
order by 
     highscore desc

这很好但我现在正尝试使用id中的连接来更新表。

UPDATE players 
SET players.rank = leaderboard.rank 
FROM players 
JOIN leaderboard ON players.id = leaderboard.id

但在mysql中出错?指针会很好

错误是

  

...在'FROM players JOIN排行榜ON附近使用正确的语法   第1行的players.id = leaderboard.id

1 个答案:

答案 0 :(得分:0)

也许是这样的:

UPDATE players 
JOIN leaderboard ON players.id = leaderboard.id
SET players.rank = leaderboard.rank

Mysql语法与tsql不同。这种风格适用于mssql