Because InnoDB default is Row-Level Lock, so the only "clear" in the specified primary key , MySQL will perform Row lock (lock only data cases to be selected), or else MySQL will perform Table Lock (to lock the entire data form live).
For example: Suppose there is a form products, there are two fields id with name, id is the primary key.
Example 1: (explicitly specify the primary key, and there is this pen data, row lock)
SELECT * FROM products WHERE id='3' FOR UPDATE;
SELECT * FROM products WHERE id='3' and type=1 FOR UPDATE;
Example 2: (explicitly specify the primary key, if no such check pen data, no lock)
SELECT * FROM products WHERE id='-1' FOR UPDATE;
Example 2: (no primary key, table lock)
SELECT * FROM products WHERE name='Mouse' FOR UPDATE;
Example 3: (primary key is not clear, table lock)
SELECT * FROM products WHERE id<>'3' FOR UPDATE;
Example 4: (primary key is not clear, table lock)
SELECT * FROM products WHERE id LIKE '3' FOR UPDATE;
Note 1: FOR UPDATE only applies to InnoDB, and must take effect at the transaction (BEGIN / COMMIT) in.
Note 2: To test the lock status, you can use the MySQL Command Mode, open two windows to do the test.
Also: Myisam supports only table-level locking, InnerDB added support for row-level locking (row-level locking / table-level lock) lock data can not be re-locked by other transactions, nor been modified by another transaction (modify, delete). It is a table-level locking, regardless of whether or not to record the query will lock the table.