Re: Get last serial (autoincrement) value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Mon, Sep 01, 2003 at 13:34:32 +0300,
  Andrei Verovski <andreil1@xxxxxxxxxxxxxxxx> wrote:
> 
> Anyone knows how to obtain last inserted serial (autoincrement) id? I 
> am currently using "SELECT id FROM table_name ORDER BY id DESC", and 
> then retrieve first row and desired value.

How you want to do this, depends on what you what to do with the number.

Normally if you just inserted a record that would create a new id and you
want to use that id to enter in another table, then you want to call
currval.


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux