List:MySQL ODBC« Previous MessageNext Message »
From:Michael Widenius Date:September 15 1999 10:04pm
Subject:locking records
View as plain text  
>>>>> "Federico" == Federico Balbi <fbalbi@stripped>
> writes:

Federico> Hello folks,
Federico>   I need to have multiple users working on an application using MySQL and 
Federico> people can update records concurrently, in same cases even the same 
Federico> record but different fields. My question is: does anybody have experience 
Federico> on locking policies and what should be best to implement or use in a case 
Federico> like this? What concerns me more is the case 2 or more users edit/update 
Federico> different fields of the same record.


The simple option is to store the original row and when you update the 
row you specify the important columns that must be kept together in
the WHERE clause:

UPDATE table_name SET column='new value' WHERE primary_key=id and
column='old_value' and related_column='old value for related column'

'affected rows' will be 0 if someone updated the row between the
row was read and it was updated.

locking recordsFederico Balbi11 Sep
  • locking recordsJani Tolonen13 Sep
  • locking recordsMichael Widenius16 Sep