From: Bruno Wolff III <bruno@wolff.to>
To: Andrei Verovski <andreil1@mail.starlett.lv>
Cc: pgsql-php@postgresql.org
Subject: Re: Get last serial (autoincrement) value
Date: Mon, 1 Sep 2003 14:01:22 -0500
Message-ID: <20030901190122.GA1782@wolff.to> (raw)
In-Reply-To: <DF9C8135-DC67-11D7-B235-000A959C9730@starlett.lv>
References: <DF9C8135-DC67-11D7-B235-000A959C9730@starlett.lv>
On Mon, Sep 01, 2003 at 13:34:32 +0300,
Andrei Verovski <andreil1@mail.starlett.lv> 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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: bruno@wolff.to, andreil1@mail.starlett.lv
Subject: Re: Get last serial (autoincrement) value
In-Reply-To: <20030901190122.GA1782@wolff.to>
References: <DF9C8135-DC67-11D7-B235-000A959C9730@starlett.lv> <20030901190122.GA1782@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox