Re: select first occurrence of a table

From: nolan(at)celery(dot)tssi(dot)com
To: pgsql-general(at)postgresql(dot)org (pgsql general list)
Subject: Re: select first occurrence of a table
Date: 2003-05-02 17:53:18
Message-ID: 20030502175318.6914.qmail@celery.tssi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> > I have a table that happens to have a some
> > duplicate entries in it (entire rows). I would like
> > to update one row and change one thing
> > about it, but it seems that I need a unique value
> > to do it; otherwise, I wind up changing multiple
> > rows.

If you don't care which of the two rows you change (and if they're
identical why would you?), you could do it with the following:

update foo set field1 = 'ZZZ' where oid =
(select min(oid) from foo where field2 = 'XXX');

max(oid) would work too.
--
Mike Nolan

Browse pgsql-general by date

  From Date Subject
Next Message Dennis Gearon 2003-05-02 17:58:23 Re: select first occurrence of a table
Previous Message Erik Ronström 2003-05-02 17:33:08 Re: select first occurrence of a table