title: Check if exists within SQL CASE statement
body: <p>I am trying to update a column in table <code>a</code> based on whether a different column in the table is in a set of results from table <code>b</code>. Currently variations on:</p>
  
  <pre><code>update a
  set a.field1 =
   case
   when exists (
     select b.field2
     from b
     where b.field2 = a.field2
   )
   then 'FOO'
   else 'BAR'
   end
  </code></pre>
  
  <p>are not running. Any ideas how to do this for a DB2 database?</p>
  
  <p><strong>Edit</strong>: Thanks for your answers, best I can do is</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>But I'll leave this open in case someone can find a version of the code at the top that works.</p>