From: | Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il> |
---|---|
To: | s-fery(at)kkt(dot)sote(dot)hu, Postgresql sql <pgsql-sql(at)postgreSQL(dot)org> |
Subject: | Re: [SQL] select in update |
Date: | 1998-11-24 11:27:30 |
Message-ID: | l03110700b28047415e6d@[147.233.159.109] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
At 12:05 +0200 on 24/11/98, Engard Ferenc wrote:
> 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.)
It's a bit hard to understand what you want to be done, and what you
*don't* want to be done.
The above seems to be the right update. But you better give a short example
of what you want. In the example you gave, if the data is:
A
==
1
2
3
4
B
==
var1 var2
==== ====
10 1
30 3
50 5
Then after the update, A will be:
10
2
30
4
This is because 1 and 3 were matched, and 2 and 4 weren't matched. If that
is what you wanted, then your update statement is correct.
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 1998-11-24 12:04:57 | Re: [HACKERS] Re: [SQL] cursor and update + view |
Previous Message | Vadim Mikheev | 1998-11-24 10:33:29 | Re: [SQL] cursor and update + view |