I am trying to update a column in table a based on whether a different column in the table is in a set of results from table b. Currently variations on:
update a
set a.field1 =
case
when exists (
select b.field2
from b
where b.field2 = a.field2
)
then 'FOO'
else 'BAR'
end
are not running. Any ideas how to do this for a DB2 database?
Edit: Thanks for your answers, best I can do is
update a set field1 = 'FOO' where field2 in (select field2 from b);
update a set field1 = 'BAR' where field2 not in (select field2 from b);
But I'll leave this open in case someone can find a version of the code at the top that works.