Re: last row of table after csv import

From: "Daniel Staal" <DStaal(at)usa(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: last row of table after csv import
Date: 2011-10-18 13:52:56
Message-ID: d09e52055ea3769ef21c26cf5006499f.squirrel@www.magehandbook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


On Tue, October 18, 2011 7:34 am, Henry Drexler wrote:

> perhaps first do a
> select
> count(*) from table
>
> then
>
> select
> *
> from
> table
> limit 1 offset (the result of your count(*) -1)

This would get you a random row of the table. (Just a different random
row than without the offset.)

Easiest solution would be to add a new field to the table, that is an
increasing counter, and take the highest value of that counter.

But I have to ask: What is the actual problem you are trying to solve?
There's probably a better solution than getting the 'last row'.

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author. Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes. This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andy Halsall 2011-10-18 16:23:25 Functions returns to libpq with wrong column split
Previous Message Thomas Kellerer 2011-10-18 12:34:00 Re: last row of table after csv import