title: SQL optimizing query
body: <p>I have a table that has the following records:</p>
  
  <pre><code>    ID | Username | Selected |
     ----------------------------
      1  |  JamesC  |     1    |
      2  |  MikeF   |     0    |
      3  |  JamesC  |     0    |
  </code></pre>
  
  <p>I wish to have Selected be true for only 1 row where the username is the same. So for example when I set <code>ID = 3</code> to be <code>Selected = true</code> I wish to set<code>ID =1</code> to have <code>Selected = false</code> as well as any other ID's with the same username.</p>
  
  <p>Right now i'm doing this, </p>
  
  <pre><code>//set all to 0
  update table set selected = 0 where username = '$username'
  
  //set unique row to true
  update table set selected = 1 where username = '$username' and ID = '$ID';
  </code></pre>
  
  <p>Is there a better more concise way of achieving the same effect?</p>