Re: How do I select the last Id in a column???

From: Michael Kovalcik <makd32(at)yahoo(dot)com>
To: Josh Goldberg <josh(at)4dmatrix(dot)com>, Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Michael Kovalcik <makd32(at)yahoo(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: How do I select the last Id in a column???
Date: 2003-06-27 21:31:30
Message-ID: 20030627213130.17702.qmail@web11106.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

All,

i got the answer i was needing. I used the following:

select max(id) from table

it works great!! :)

--- Josh Goldberg <josh(at)4dmatrix(dot)com> wrote:
> What could cause a table to act serialized when read
> committed transactions
> are set in the configuration? That is something I
> am running into, which
> provoked my [incorrect] example.
>
> From: "Bruno Wolff III" <bruno(at)wolff(dot)to>
> Sent: Thursday, June 26, 2003 4:30 PM
> > On Thu, Jun 26, 2003 at 14:00:33 -0700,
> > Josh Goldberg <josh(at)4dmatrix(dot)com> wrote:
> > > to get the last record inserted just
> > > select * from row order by autoincId desc limit
> 1;
> > >
> > > if you have several clients doing this you might
> want to put your insert
> and
> > > the select inside a transaction.
> >
> > That won't help. Your suggestion will only work in
> serializable
> transactions.
> >
> > In read committed mode the select might see a
> value for autoincId from
> > a transaction that committed between the insert
> and the select.
> >
> > ---------------------------(end of
> broadcast)---------------------------
> > TIP 8: explain analyze is your friend
> >
>

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message scott.marlowe 2003-06-27 21:42:45 Re: How do I select the last Id in a column???
Previous Message Michael A Nachbaur 2003-06-27 20:54:36 SQLRelay?