mySQL query question
| From: | ceo at l-i-e dot com | Date: | Fri, 14 Nov 2008 14:58:21 +0000 |
| Subject: | mySQL query question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-283299@lists.php.net to get a copy of this message | ||
> okay I want to pull an integer from a database called confirm_number,
> add 1 and repost it back to the database
No, you don't want to do that.
:-)
You are introducing a race condition between TWO users who hit the same page at the same time.
They each get, say, 42, and they each put back 43, but one of them should have been 44.
What you WANT to do is this:
update contacts set confirm_number = confirm_number + 1 order by contact desc limit 1