How to lock a single row

svk picture svk · Oct 7, 2010 · Viewed 63.2k times · Source

I have a user table with field lastusedecnumber.

I need to access and increment lastusedecnumber.

During that accessing time I need to lock that particular user row (not the entire table).

How do I do this?

The table type is MyISAM.

Answer

belwood picture belwood · Oct 7, 2010

MySQL uses only table-level locking from MyISAM tables. If you can, switch to InnoDB for row-level locking.

Here's a link to the MySQL site describing Locks set by SQL Statements for InnoDB tables. http://dev.mysql.com/doc/refman/5.0/en/innodb-locks-set.html