Search Postgresql Archives

Re: Using a CTE for an update

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

 



On 05/31/13 15:33, David Salisbury wrote:
> 
> And without trying too much ;), I'll bet there is no way to do this in SQL proper.  i.e.
> I can't correlate an update with a select stmt, as in a correlated sub-query sort of way.
> So for this to work I would indeed need to write a function that "hard codes" the values
> within the update stmt.

I think this is what you want:

update atmos_sites asites
   set stationid = my.stationid
   from my_stations my
   where asites.id = my.atmos_site_id;

HTH

Bosco.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[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 Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux