Re: Get last serial (autoincrement) value - Mailing list pgsql-php

From Frank Bax
Subject Re: Get last serial (autoincrement) value
Date
Msg-id 5.2.1.1.0.20030901144559.00a0c3e0@pop6.sympatico.ca
Whole thread Raw
In response to Get last serial (autoincrement) value  (Andrei Verovski (aka MacGuru) <andreil1@mail.starlett.lv>)
List pgsql-php
At 06:34 AM 9/1/03, aka MacGuru 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.


Faster then your version:
SELECT id FROM table_name ORDER BY id DESC   LIMIT 1

The 'elegant' solution:
SELECT currval('tablename_sequence_id');


pgsql-php by date:

Previous
From: "David Busby"
Date:
Subject: Re: Get last serial (autoincrement) value
Next
From: Bruno Wolff III
Date:
Subject: Re: Get last serial (autoincrement) value