help with simple SQL update + join -


i think should pretty simple, i'm sql newb.

i have 2 tables. 1 list of items ids , descriptions, other map of corresponding old , new ids. this:

    id_map old_id   new_id --------------- 1        101 2        102      items id       description -------------------- 1        "itema" 2        "itemb" ... 101      <null> 102      <null> 

i need copy old item descriptions new items according map. think need use inner join inside of update, it's not working , i'm not sure that's right way go.

i'm trying statements like

update items set (select items.description      items      join id_map      on items.id = id_map.new_id) =      (select items.description      items      join id_map      on items.id = id_map.old_id) 

but of course it's not working. should doing?

update new_item     set description = old_item.description     items old_item         inner join id_map im             on old_item.id = im.old_id         inner join items new_item             on im.new_id = new_item.id 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -