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

Поиск
Список
Период
Сортировка
От Patrick JACQUOT
Тема Re: [SQL] found a way to update a table with data from another one
Дата
Msg-id 3844EB46.EDFA7129@anpe.fr
обсуждение исходный текст
Ответ на Re: [SQL] found a way to update a table with data from another one  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
Tom Lane wrote:

> Patrick JACQUOT <patrick.jacquot@anpe.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



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Gerhard Dieringer"
Дата:
Сообщение: Antw: [SQL] Many booleans
Следующее
От: pez@aiming.net
Дата:
Сообщение: Partial Search