title: How to assign a record to a person from a pool automatically using MySQL/PHP while preventing across assignment
body: <p>I have a script that is written in PHP. It uses MySQL database to store records.</p>
  
  <p>Basically, I have team of users that are making random calls to a different business. I want to add list of phone number in a queue "pool table". The system will need to assign the new call to the user. Now If a user is already working on a phone call I don't want another user to start calling the same number. I need a solution to prevent 2 people having the same record assigned to them. So if phone number 000-000-0000 is assigned to the user X the same record will be skipped and the next one in line get assigned to the next available user.</p>
  
  <p>This table will be accessed a lot so I need a good solution that will prevent 2 people from working on the same record and also not cause system issues.</p>
  
  <p>One way I can think of but looking for a better solution is</p>
  
  <ol>
  <li>open transaction</li>
  <li>select a call where record status is available</li>
  <li>update that call by changing the status from records available to record pending.</li>
  <li>commit transaction.</li>
  </ol>
  
  <p>If the use completed the call then updated with a status of completed otherwise make the record available again.</p>
  
  <p>what are other solution available for me?</p>
  
  <p>Thanks</p>