-- fetch 10 to avoid querying too many times.... SELECT * FROM tablex ORDER BY dateofinsertion LIMIT 10; -- Mark the register as owned by you UPDATE tablex SET controlfield=controlfield+1 WHERE id=$id AND controlfield=$controlfieldvalue; #### if ($sth->rows) { # it did the update, so the row is mine. } else { # someone else took the register, let's try another one }