I assign the first available row to each coming user as
SELECT id FROM table1 WHERE status IS NULL ORDER BY id LIMIT 1
fetched id is xxx
UPDATE table1 SET status='taken' WHERE id=xxx
How can I make sure that not a second user retrieve the same id before it is UPDATEd as taken?
NOTE: It has nothing to do with INSERT. The table is already there. Users should take the first available row. UPDATE is just to keep track of taken rows.