Re: [SQL] found a way to update a table with data from another one

From: Patrick JACQUOT <patrick(dot)jacquot(at)anpe(dot)fr>
To: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] found a way to update a table with data from another one
Date: 1999-12-01 09:32:55
Message-ID: 3844EB46.EDFA7129@anpe.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tom Lane wrote:

> Patrick JACQUOT <patrick(dot)jacquot(at)anpe(dot)fr> writes:
> > I found a simpler way to do the job I wanted done
>
> > UPDATE t1 SET balance = balance+t2.amount WHERE EXISTS (SELECT *
> > FROM t2 WHERE t2.id = t1.id)
>
> > DOES WORK PROPERLY.
>
> Does it? I don't think that this will do what you are expecting,

<snip>
I thank you very much for your advice. I didn't try indeed to
put more than one line in T2.
I tried before to use your approach bu i used the wrong syntax :
UPDATE t1 SET Balance=Balance+(SELECT Amount FROM t2 WHERE t2.id=t1.id);
which gave me 'parser : parser error near select'.
I am really sorry havig done such a mistake, and apologize
Next time i'll turn my tongue seven times in my mouth before
going to my keyboard.
Best regards
P. Jacquot

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message pez 1999-12-01 14:07:48 Partial Search
Previous Message Gerhard Dieringer 1999-12-01 08:34:11 Antw: [SQL] Many booleans