title: MySQL Update Column from other column in same table
body: <p>I added a new column, supervisor_id, to a USERS table that I need to populate from the same USERS table:</p>
  
  <pre><code>ID   |  USERNAME  |  SUPERVISOR_USERNAME  |  SUPERVISOR_ID
  
  1    |  jdoe      |  jsmith               | NULL
  
  2    |  jsmith    |  dduck                | NULL
  </code></pre>
  
  <p>How would I loop through the table to set the supervisor_id = id, like this:</p>
  
  <pre><code>ID   |  USERNAME  |  SUPERVISOR_USERNAME  |  SUPERVISOR_ID
  
  1    |  jdoe      |  jsmith               |  2
  
  2    |  jsmith    |  dduck                | NULL
  </code></pre>
  
  <p>I tried the following, but it obviously only set the supervisor_id where the user's supervisor_username was his own username.  </p>
  
  <pre><code>update users
  set supervisor_id = id
  where supervisor_username = username
  </code></pre>