On Mon, Nov 12, 2001 at 11:29:48PM -0800, Jeremy Zawodny wrote: > On Mon, Nov 12, 2001 at 10:52:39PM -0800, Bennett Haselton wrote: > > Say I have two running programs and both of them periodically want to > > increment a value in a database. How can I do this so that the increments > > will be performed correctly even if the two programs try to do them at the > > same time? > > > > If I have code like this: > > > > $x = read_value_from_database(); > > ++$x; > > write_value_to_database($x); > > UPDATE mytable SET col = col+1;
With an appropriate WHERE clause, of course. :-) -- Jeremy D. Zawodny, <[EMAIL PROTECTED]> Technical Yahoo - Yahoo Finance Desk: (408) 349-7878 Fax: (408) 349-5454 Cell: (408) 685-5936 MySQL 3.23.41-max: up 68 days, processed 1,510,494,591 queries (254/sec. avg) --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php