select - MySQL update with a subquery -


i trying update specific row in table based on value in table, can't seem figure out how it:

update users set a.val = (select value users userid = 4) a.userid = 1 

but getting error

lookup error - mysql database error: can't specify target table 'a' update in clause 

any ideas missing here?

use join syntax , non-equi join

update users join users b     on a.userid = 1    , b.userid = 4    set a.value = b.value 

here sqlfiddle demo


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -