List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:October 22 2002 2:55am
Subject:Re: Using AUTO_INCREMENT like SEQUENCE - Resolved
View as plain text  
At 16:57 +0200 10/21/02, Joseph Bueno wrote:
>Hi all,
>
>Sorry to jump in the middle of this thread but there is a much simpler
>way to generate sequence numbers:
>
>You create an auxiliary table with a one row:
>CREATE TABLE sequence (
>   code int(11) DEFAULT '0' NOT NULL
>);
>INSERT INTO sequence VALUES (0);
>
>And, each time you need a new sequence number:
>	UPDATE sequence SET code=LAST_INSERT_ID(code+1);
>	SELECT LAST_INSERT_ID();
>
>We use this method in our applications and it works well.
>(and I didn't invent it, it is described in Paul DuBois'book ;))

And I didn't invent it, either, it's described in the MySQL manual! :-)

Thread
RE: Using AUTO_INCREMENT like SEQUENCE - ResolvedChuck Tomasi21 Oct
  • RE: Using AUTO_INCREMENT like SEQUENCE - ResolvedMike Hillyer21 Oct
    • Re: Using AUTO_INCREMENT like SEQUENCE - ResolvedJoseph Bueno21 Oct
      • Re: Using AUTO_INCREMENT like SEQUENCE - ResolvedPaul DuBois22 Oct