found a way to update a table with data from another one

Поиск
Список
Период
Сортировка
От Patrick JACQUOT
Тема found a way to update a table with data from another one
Дата
Msg-id 3843BDFD.4EF1BACE@anpe.fr
обсуждение исходный текст
Ответы Re: [SQL] found a way to update a table with data from another one
Список pgsql-sql
Hi everybody
I've read a quite old posting about the impossibility of updating a
view.
e.g.

Let t1 (Id, balance) and t2 (id, amount) be two tables

DEFINE VIEW U AS SELECT balance, amount FROM t1, t2 WHERE t1.id=t2.id;
UPDATE U SET balance=balance+amount

without writing a rule

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.




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

Предыдущее
От: Thilo Mezger
Дата:
Сообщение: unixtime -> datetime
Следующее
От: "Emils Klotins"
Дата:
Сообщение: Addendum: PG6.5.3: CASE w. diff THEN types -- prob with Linux(?)