From: | "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com> |
---|---|
To: | "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com> |
Cc: | "pg-general (E-mail)" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: select first occurrence of a table |
Date: | 2003-05-02 16:57:29 |
Message-ID: | Pine.LNX.4.33.0305021056230.24538-100000@css120.ihs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 2 May 2003, Johnson, Shaunn wrote:
> Have a general SQL question:
>
> 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.
>
> For example: I have a table that looks like this
>
> [snip table]
>
> Table "survey_processed_dt"
> Column | Type | Modifiers
> -------------------+---------------------------+-----------
> survid | character(8) |
> processed_id | character varying(2) |
> processed_dt | date |
>
> [/snip table]
>
> And the rows look like this:
>
>
> [snip rows]
>
> bcn=> select * from survey_processed_dt where survid = '02021000' and
> processed_id = '05';
> survid | processed_id | processed_dt
> ----------+--------------+--------------
> 02021000 | 05 | 2003-01-16
> 02021000 | 05 | 2003-01-16
> (2 rows)
>
> [/snip rows]
>
> I want to change ONE of the rows ... is there a way to
> just select the first occurrence of a row to update?
If you've got a table that was created with oids, you can do:
select *,oid from survey_processed_dt where survid = '02021000' and
processed_id = '05';
then you can change just the one with the OID.
From | Date | Subject | |
---|---|---|---|
Next Message | Ivan | 2003-05-02 16:58:03 | bytea data |
Previous Message | Johnson, Shaunn | 2003-05-02 16:15:13 | select first occurrence of a table |