Re: selecting the last record from a table

From: Doug McNaught <doug(at)mcnaught(dot)org>
To: MT <mt(at)open2web(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: selecting the last record from a table
Date: 2002-11-19 19:07:52
Message-ID: m38yzpl6nr.fsf@varsoon.wireboard.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

MT <mt(at)open2web(dot)com> writes:

> I have a script that inserts a record into a table and increments the
> unique field using nextval('my_sequence'). My problem is once I have
> inserted the record, I'd like to select this same record and display
> it so that the user knows he has actually inserted the record. I'm
> wondering if there's a bit of sql to select the last record.

SELECT * FROM mytable WHERE my_unique_field = currval('my_sequence');

-Doug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2002-11-19 19:17:08 Re: Update table with max occurance from another table
Previous Message MT 2002-11-19 18:54:23 selecting the last record from a table