Q:

Mysql innodb row lock doesn't work

Iam using mysql v5.6 .
When i send the following mysql query using php which will select some rows also locking them:
SELECT * FROM accounts WHERE id = 1 FOR UPDATE;

I get the following error message:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your Mysql server version for the right syntax to use near 'LIMIT 0, 25' at line 2 

Thanks

A:

Mysql innodb row lock doesn't work
Now, I think its problem is you should not use the transaction not started that only make big different so, you should must START TRANSACTION like my code, and 
some times it was happens when in a running transaction, two identical statements get different values, because some other transaction has modified the table’s rows. 
like your as following as: 
transaction1> START TRANSACTION;
transaction1> SELECT * FROM accounts WHERE id=1 FOR UPDATE;

For example: 
transaction1> SELECT first_name, last_name FROM customer WHERE id = 3 FOR UPDATE;

+------------+-----------+
| first_name | last_name |
+------------+-----------+
| JMAIL      | KRISH     |
+------------+-----------+

1 row in set (0.00 sec)

you should refer this link:
http://www.mysqlperformanceblog.com/2012/03/27/innodbs-gap-locks/
http://dev.mysql.com/doc/refman/5.1/en/innodb-locks-set.html
https://stackoverflow.com/a/22007412/3242978

