Re: select first occurrence of a table - Mailing list pgsql-general

From nolan@celery.tssi.com
Subject Re: select first occurrence of a table
Date
Msg-id 20030502175318.6914.qmail@celery.tssi.com
Whole thread Raw
In response to select first occurrence of a table  ("Johnson, Shaunn" <SJohnson6@bcbsm.com>)
List 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


pgsql-general by date:

Previous
From: Erik Ronström
Date:
Subject: Re: select first occurrence of a table
Next
From: Dennis Gearon
Date:
Subject: Re: select first occurrence of a table