From: | Engard Ferenc <fery(at)pons(dot)sote(dot)hu> |
---|---|
To: | Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>, Postgresql sql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: [SQL] select in update |
Date: | 1998-11-24 10:05:27 |
Message-ID: | Pine.LNX.3.96.981124104050.6087C-100000@Pons.sote.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Tue, 24 Nov 1998, Herouth Maoz wrote:
>The long-standing syntax for this in PostgreSQL is:
>
>UPDATE shorttest2
>SET b=t1.b
>FROM shorttest t1
>WHERE t1.a=1;
>
>Please, look up the manpages for the command you want to invoke, or \h it.
>You may discover syntax options that cover what you need. I have PostgreSQL
Thx for the help! Anyway, I have read the docs, but since there is no
example there, and I didn't know this syntax (and maybe my english is not
so good), I couldn't figure out what is this strange FROM clausule... :))
Well, then a little bit complex problem:
two tables: A (var), B (var1,var2). I would like to replace the A.var
if it exists in B.var2 with B.var1. Is it good?
UPDATE a
SET a.var=b.var1
FROM b <-- or maybe I need to put 'a' here too?
WHERE a.var=b.var2;
I don't need to tell that there are rows which cannot find in B? (In
this case it shouldn't change.)
I feel that I need to write two different WHERE-s: one for the subquery
(which then results 1 row), and one for the UPDATE, to tell where to
put that value. I solved this until now with a 'c' prg.
Thanks again and bye:
Circum
__ @
/ \ _ _ Engard Ferenc
l | ( \ / | | (\/) mailto:s-fery(at)kkt(dot)sote(dot)hu
\__/ | | \_ \_/ I I http://pons.sote.hu/~s-fery
From | Date | Subject | |
---|---|---|---|
Next Message | Vadim Mikheev | 1998-11-24 10:33:29 | Re: [SQL] cursor and update + view |
Previous Message | Jan Wieck | 1998-11-24 09:31:38 | Re: [SQL] cursor and update + view |