0
UPDATE PlayerLeague l 
JOIN PlayerStat s ON l.player_id=s.player_id 
SET l.league_id=8 
WHERE l.league_id=2 
ORDER BY s.score 
DESC LIMIT 5

そして、私はエラーがあります:

{ [Error: ER_WRONG_USAGE: Incorrect usage of UPDATE and ORDER BY] 
code: 'ER_WRONG_USAGE', index: 0 }

どういう意味?

私はこれを試します:

UPDATE PlayerLeague l 
SET l.league_id=8 
WHERE l.player_id IN 
(SELECT player_id FROM PlayerStat s 
JOIN PlayerLeague l ON s.player_id=l.player_id 
WHERE l.league_id=2 
ORDER BY s.score 
DESC LIMIT 5)

しかし、これも間違っています。

4

2 に答える 2

1

私は解決策を見つけました:

UPDATE PlayerLeague l 
JOIN (SELECT s.player_id 
    FROM PlayerStat s 
    JOIN PlayerLeague l 
    ON s.player_id=l.player_id 
    WHERE l.league_id=2 
    ORDER BY s.score DESC LIMIT 5
) AS temp
ON l.player_id=temp.player_id
SET l.league_id=8 
于 2013-10-12T05:32:10.197 に答える