mysql - How to write a query with join, update and order by? -


i have 2 tables: tblrider , tbl_score. tblrider has information riders (competitors) , in tbl_score riders's scores saved. want update column halfpipefinal in tblrider. standard column set on 0, want set on 1 riders 20 best scores. (so 20 best riders can participate in final , have 1 in column halfpiperider)

this query:

update tblrider join tbl_score on tblrider.riderid = tbl_score.riderid set tblrider.halfpipefinal = 1 `gameid` =35 order `score` desc limit 20;** 

if run query error: "incorrect usage of update , order by" went looking , apparently can't use update , order in join. looking other way write query without order in it, can't find it.

all appreciated. thanks

in sql can't have order by part of update itself. can make filter subquery, give alias , join it...

update tblrider r join  (     select riderid      tbl_score     gameid = 35     order score desc     limit 20  ) s on r.riderid = s.riderid set r.halfpipefinal = 1; 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -