sql - multi-row update table with "different" data -
i think best way explain tell have.
i have 2 tables , b both have columns field1 , field2. field 2 not populated in table b
i want populate field 2 of table b field 2 of table field 1 of table matches field 1 of table b.
something update tableb set field2 = tablea.field2 tablea.field1 = tableb.field1.
the reason may seem odd , obscure i'm tyring inital data load form old database new one.
please let me know if need clarification
it sounds need correlated update
update tableb b set field2 = (select a.field2 tablea a.field1 = b.field1 ) exists( select 1 tablea a.field1 = b.field1 );
since every field2
in b null begin with, may able skip exists (in case rows in b don't have match in updated null generating bit of redo). want include update rows there match.
Comments
Post a Comment