4 messages in com.mysql.lists.mysqlRe: how to atomically (select, update)?
FromSent OnAttachments
da...@directint.net29 Feb 2000 17:56 
Nem W Schlecht29 Feb 2000 23:59 
Thimble Smith01 Mar 2000 07:07 
dave...@bfnet.com01 Mar 2000 11:30 
Subject:Re: how to atomically (select, update)?
From:Thimble Smith (ti@mysql.com)
Date:03/01/2000 07:07:15 AM
List:com.mysql.lists.mysql

On Tue, Feb 29, 2000 at 05:56:32PM -0800, da@directint.net wrote:

I have a counter in the DB that I need to read and update atomically. Currently I am basically doing this:

SELECT id FROM maxurlid; UPDATE id SET id=id+1 where id=$found_id; (then I use $found_id later)

Dave, there is a trick you can do with LAST_INSERT_ID() that will do what you want. Look in the manual at the docs for LAST_INSERT_ID, and look for where it says, "This can be used to simulate sequences:". It describes what you want to do.

Tim