From: | Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com> |
---|---|
To: | Ron <ronljohnsonjr(at)gmail(dot)com> |
Cc: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: How to write such a query |
Date: | 2020-09-18 19:45:25 |
Message-ID: | CAD3a31XmfCqz-p7Ssky53U7m4fkL0RHGZyM=RVfD5+K-RZ69Gw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>
> > How to find what the primary key (or UNIQUE identifier) value is
> > for row 5 in the recordset?
>
> You're missing the point: as mentioned before, there is no "row 5". To
> update the 5th record that you've fetched, you increment a counter each
> time
> you fetch a row, and when you read #5, do an UPDATE X SET field1 = 'blarg'
> WHERE id = <thekeyvalue>;
>
>
It seems worth mentioning for benefit of the OPs question that there _is_ a
way to get a row number within a result set. Understanding and making good
use of that is an additional matter.
SELECT X.field1, Y.field2*,row_number() OVER ()* from X, Y WHERE X.id =
Y.id -- ORDER BY ____?
That row number is going to depend on the order of the query, so it might
or might not have any meaning. But if you queried with a primary key and a
row number, you could then tie the two together and make an update based on
that.
Cheers,
Ken
--
AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ <http://agency-software.org/>*
*https://demo.agency-software.org/client
<https://demo.agency-software.org/client>*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801
Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.
From | Date | Subject | |
---|---|---|---|
Next Message | Rob Sargent | 2020-09-18 19:51:51 | Re: How to write such a query |
Previous Message | Ron | 2020-09-18 19:25:37 | Re: How to write such a query |