title: MySQL UPDATE and SELECT in one pass
body: <p>I have a MySQL table of tasks to perform, each row having parameters for a single task.<br>
  There are many worker apps (possibly on different machines), performing tasks in a loop.<br>
  The apps access the database using MySQL's native C APIs.</p>
  
  <p>In order to own a task, an app does something like that:  </p>
  
  <ul>
  <li><p>Generate a globally-unique id (for simplicity, let's say it is a number)  </p></li>
  <li><p><code>UPDATE tasks</code><br>
  <code>SET guid = %d</code><br>
  <code>WHERE guid = 0 LIMIT 1</code></p></li>
  <li><p><code>SELECT params</code><br>
  <code>FROM tasks</code><br>
  <code>WHERE guid = %d</code>  </p></li>
  <li><p>If the last query returns a row, we own it and have the parameters to run  </p></li>
  </ul>
  
  <p>Is there a way to achieve the same effect (i.e. 'own' a row and get its parameters) in a single call to the server?</p>