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@kkt.sote.hu
\__/ | | \_ \_/ I I http://pons.sote.hu/~s-fery