Thread: Update Join ?

Update Join ?

From
kevin kempter
Date:
Hi List;

Does Postgres allow updates based on the context of a sub-query, something like the sample below ?



1) Insert data (real_tab.keyID and real_tab.data_desc)  into a temp table (temp_tab)

2) update real_tab 
       set real_tab.data_desc = temp_tab.data_desc
      join real_tab on real_tab.keyID = temp_tab.keyID ;

Thanks in advance..


Re: Update Join ?

From
"Adam Rich"
Date:
>> Does Postgres allow updates based on the context of a sub-query,
something like the sample below ?

Yes,

Update real_tab
set real_tab.data_desc = temp_tab.data_desc
From temp_tab
Where real_tab.keyID = temp_tab.keyID

(don't repeat your updated table in the "from" list unless you
Mean to self-join)

http://www.postgresql.org/docs/8.3/interactive/sql-update.html