2012-05-14 113 views
0

我有一個名爲排行榜更新我的加入對臨時表

表,我創建

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玩家加入排行榜ON players.id = leaderboard.id' 在行1

+0

你會得到什麼錯誤? – Arion

回答

0

可能是這樣的:

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

Mysql的語法不同於tsql。這種風格可以在mssql上運行