oracle - SQL Update on selected rows from a lookup table -


i have tables structure following:

table1: baseobject (id, name)  table2: instance (baseobjectid, type)  table3: mapping (type, value) 

i want

update baseobject.name = mapping.value  exists instance  baseobject (instance.baseobjectid = baseobject.id)  , mapping.type = instance.type 

not able figure out how achieve in sql.

edit: following works not sure if optimal:

update baseobject  set baseobject.name = (select mapping.value                          mapping, instance                         mapping.type = instance.type                         , instance.baseobjectid = baseobject.id) exists (select instance.baseobjectid                instance                instance.baseobjectid = baseobject.id) 

update (select t1.name name,                 t3.value value           baseobject t1,                instance t2,                mapping t3          t2.baseobjectid = t1.id           ,  t3.type = t2.type)    set name = value 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

node.js - Using Node without global install -

php - CakePHP HttpSockets send array of paramms -