dukeslater
Technical User
This is a simple update, but delivering unexpected results. I need to update only the records in table1 that exist in table 2:
update table1 a
set a.code =
( select code
from table2 b
where a.custid = b.custid);
This does properly update the records that exist in both tables.
Yet for those records that do not exist in table2 the statement is replacing the code in table1 with null. Ordinarily this would suggest a join problem, but I can't see why the equal join wouldn't do what I need.
Perhaps I need to use an entirely different technique, but I'm still stumped as to why I'm getting the result that I am. Thanks in advance for your help.
update table1 a
set a.code =
( select code
from table2 b
where a.custid = b.custid);
This does properly update the records that exist in both tables.
Yet for those records that do not exist in table2 the statement is replacing the code in table1 with null. Ordinarily this would suggest a join problem, but I can't see why the equal join wouldn't do what I need.
Perhaps I need to use an entirely different technique, but I'm still stumped as to why I'm getting the result that I am. Thanks in advance for your help.