I have a table like this:
create table foo ( a number, b number )
I want to update all the columns from a with the value that is in another table
create table bar ( x number, y number )
So, if this would be a procedural programing language I would:
foreach foo_item in foo
foreach bar_item in bar
if( foo_item.b == bar_item.y )
foo_item.a = bar_item.x
end
end
end
I have tried
update foo
set a = ( select distinct( x ) from bar where bar.y = foo.b )
But it hangs.... I'm not really sure how to do such a thing ( or even what to google for )
Thanks
EDIT Sorry my bad. It doesn't hang, but it tries to set va null value and I have a constraint ( which I can't remove )
Thanks for the help so far