title: MySQL UPDATE - SET field in column to 1, all other fields to 0, with one query
body: <p>I am updating a field in a mysql column namend "frontpage", set it from 0 to 1.</p>
  
  <p>No problem with this query:</p>
  
  <pre><code>mysql_query("UPDATE table SET frontpage='1' WHERE user_id='999' AND poll_id='555'");
  </code></pre>
  
  <p>What I'd like to accomplish is, in case <code>user_id 999</code> got already other existing <code>poll_id</code>'s set to <code>1</code> in the past, these rows should be set to 0 automatically.</p>
  
  <p>As a beginner learning MySQL, I would run 2 queries, first one to set everything to <code>frontpage='0' WHERE user_id='999'</code> and the second query to set <code>frontpage='1' WHERE user_id='999' AND poll_id='555'</code>.</p>
  
  <p>My question now is, could this be done by using only one query, and how?</p>
  
  <p>PS: Not sure if it has something to do with my question, I've read these answers <a href="https://stackoverflow.com/questions/1013042/mysql-updating-all-rows-setting-a-field-to-0-but-setting-one-rows-field-to-1">MySQL: Updating all rows setting a field to 0, but setting one row&#39;s field to 1</a> but I haven't really understood the logic, perhaps someone can explain it to a mysql beginner please.</p>