title: Is this update, select combination query thread safe?
body: <p>I have a table called seats, which has a schema like this</p>
  
  <blockquote>
    <p>id,taken</p>
  </blockquote>
  
  <p>For each user, I take a random untaken id and assign to that user, here for simplicity say, I make taken =1. The query I am using</p>
  
  <pre><code>   update seats u inner join  (
          SELECT id from seats  
          where taken is null limit 1) s 
     on s.id = u.id set taken = 1;
  </code></pre>
  
  <p>This query takes a random seat with taken flag null, and for that seat it makes the flag 1. While this query is working fine, is this  thread safe?</p>
  
  <p>Consider this scenario, I have two users in parallel. For user1, I select row X, and just before update query is ran user2 checks in, and for that user select query returns the same row as user1. So I will end updating the same row twice.</p>
  
  <p>Is this scenario possible with this query? </p>