Re: Simple SQL-syntax

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Simple SQL-syntax
Дата
Msg-id web-105447@davinci.ethosmedia.com
обсуждение исходный текст
Ответ на Simple SQL-syntax  ("Fredrik Thunberg" <fredrik@datessa.se>)
Ответы Re: Simple SQL-syntax
Список pgsql-sql
Robby,

> Do you know if, internally there's any difference between
> 
> UPDATE A,B SET a.f1 = b.f1 WHERE a.i = b.i;
> 
>   -and-
> 
> UPDATE A SET a.f1 = b.f2 FROM B WHERE a.i = b.i;
> 
> Just wondering why the SQL standard would be broken in this
> case---and if there's any reason to learn this particular
> aspect of Postgres functionality....

Only if you want to use JOINS, sub-selects, and/or aliasing in your
UPDATE statement.  For example, I have a table that caches subtotals of
its detail-level subtable:

UPDATE invoice SET invoice_total = total_of_items
FROM (SELECT invoice_id, sum(item_amount) FROM invoice_items) iit
WHERE iit.invoice_id = invoices.id;

-Josh Berkus


______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco
 


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

Предыдущее
От: "omid omoomi"
Дата:
Сообщение: split/explode functions
Следующее
От: Laurette Cisneros
Дата:
Сообщение: quick server c question