title: MYSQL Update from within same table
body: <p>I have a table with some data that has gone wrong, that I need to fix up.  Below is an example:</p>
  
  <pre><code>TABLE-A
  id, type, value
  1, 10, 123456
  2, 10, NULL
  3, 10, NULL
  4, 20, 123456
  5, 20, 654321
  6, 20, NULL
  </code></pre>
  
  <p>I need a MYSQL update command.</p>
  
  <p>If the "type" is the same then update the "value" so it is the same as long as the value is NULL and the "value" is unique</p>
  
  <p><code>UPDATE table-a SET value = (...)</code></p>
  
  <p>So in the table above only <code>id 2</code> and <code>3</code> will have the value updated to 123456</p>
  
  <p><code>id 6</code> will not update as the "value" is not unique for the the same "type".</p>