title: Reduce not null duplicate rows in MySQL from many to one
body: <p>I need an <code>update</code> statement to resolve some issues with duplicates in a table on MySQL. The table structure is shown below. I need a MySQL statement that will set the value of duplicate as <code>NULL</code> except the first one, i.e the one with the lowest id. Here the id is the primary key.</p>
  
  <p>This is an example of what I have:</p>
  
  <pre><code> id       name
    1        foo
    2        foo
    3        bar
    4        NULL
    5        NULL
    6        foo
    7        bar
  </code></pre>
  
  <p>This is the desired result:</p>
  
  <pre><code> id        name 
    1        foo
    2        NULL
    3        bar
    4        NULL
    5        NULL
    6        NULL
    7        NULL
  </code></pre>
  
  <p>The table has other columns with useful information. Hence, the row can't just simply be deleted.</p>