MySQL Forums
Forum List  »  Newbie

Increment Function
Posted by: Ian Biner
Date: April 27, 2005 04:52PM

Hello,

I'm trying to create a counter.
The way it's currently structured, I find the record I'm looking for, extract the last number from the counter field, add 1 to that number, then update the record.

That's two calls to mySQL, with a few lines of php code in between. If I wanted to lock the record, I'd need to build a little loop that checks its lock status, otherwise, a user could access the record in the time in between a user reading it and then re-writing it. That seems inefficient.

Is there an SQL function that simply allows me to increment a numeric field (not auto-increment... this is a counter, not a record number)?

Thanks
Ian

Options: ReplyQuote


Subject
Written By
Posted
Increment Function
April 27, 2005 04:52PM
April 28, 2005 01:42AM
April 28, 2005 07:40AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.