This is a delay for. In all major SQL implementations, DML statements are blocked by default, so one query will not overwrite another until the first is complete.
There are different levels of blocking. If you have row locking, your second update will work in parallel with the first, so at some point you will have 1 s and 2 in your table.
A table lock will cause the second query to wait for the completion of the first query to release the table lock.
Usually you can disable the lock directly in your SQL, but this is only ever done if you need to improve performance and you know that you will not encounter race conditions, as in your example.
Editing based on the new MySQL tag
If you are updating a table that uses the InnoDB , then you are working with row locking, and your query could give a table with 1 and 2.
If you are working with a table using the MyISAM mechanism, then you are working with table locking, and your update instructions will have a table in which there will be either all 1 or all 2s.
source share