Search Postgresql Archives

Re: UPDATE-FROM and INNER-JOIN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 5, 2024 at 7:36 AM Dominique Devienne <ddevienne@xxxxxxxxx> wrote:
I'd rather SQLite and PostgreSQL continue to agree on this,
but not in a restrictive way.

I.e., you want to support the SQL Server syntax; allow the table named in UPDATE to be repeated, without an alias, in which case it is taken to represent the table being updated.  And then allow the usual FROM clause to take form.

Personally I get around this by simply doing:

UPDATE tbl
FROM (...) AS to_update

A bit more verbose in the typical case but the subquery in FROM can be separately executed during development then just plugged in.  There is no noise in the outer where clause since its only purpose is to join the subquery to the table to be updated.  The subquery has the full separation of filters from joins that one would like to have.

David J.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux