LOCK TABLES tbl_name [AS alias] {READ | [LOW_PRIORITY] WRITE}, tbl_name ...
LOCK TABLES locks the specified table(s) so that the current connection has exclusive access to them, while other connections will have to wait until the lock is released with UNLOCK TABLES, with another LOCK TABLES query, or with the closure of the current connection.
A READ lock prevents the specified table(s) from being written by this, or any other connection. This allows you to make certain that the contents of a table (or set of tables) are not changed for a certain period of time.
A WRITE lock prevents all other connections from reading or writing the specified table(s). It's useful when a series of INSERT or UPDATE queries must be performed together to maintain the integrity of the data model in the database. New support for transactions in MySQL provides more robust support for these types of “grouped queries” (see the sidebar in "LOCK ing TABLES" for details).
By default, a WRITE lock that is waiting for access to a table will take priority over any READ locks that may also be waiting. To specify that a WRITE lock should yield to all other READ lock requests, you can use the LOW_PRIORITY option. Be aware, however, that if there are always READ lock requests pending, a LOW_PRIORITY WRITE lock will never be allowed to proceed.
When locking tables, you must list the same aliases that you’re going to use in the queries you will be performing. If, for example, you are going to refer to the same table with two different aliases in one of your queries, you will need to obtain a lock for each of those aliases beforehand.
For more information on locking tables, see "LOCK ing TABLES".