In article <466f16f2$0$90276$14726298 (AT) news (DOT) sunsite.dk>, Nis Jørgensen
<nis (AT) superlativ (DOT) dk> wrote:
Quote:
Since you do not write which database you use, i will assume you are
using postgresql 8.1. In that case you can do
UPDATE clients SET clients.source = sources.source
FROM sources
WHERE clients.client_id = sources.client_id
An approach which should work in any db that supports subselects:
UPDATE clients SET clients.source = (SELECT source FROM sources WHERE
clients.client_id = sources.client_id)
WHERE client_id in (SELECT client_id FROM sources)
Hope these helps |
Yes it does. Thank you very much.
So let me try to understand how it works (using the second version).
First it finds the set of clients who have a corresponding row in
sources (the 'outside' part of the statement), then it updates the
column using the 'inner' select?
I am finding it difficult to think in terms of sets and 'simultaneous'
actions. I keep wanting to solve these things procedurally.
Thanks again.