Search Postgresql Archives

Re: update one table with another

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

 



On Apr 20, 2009, at 10:34 PM, Matthew Pugsley wrote:

I've solved it.

I just used a subselect. Worked very quickly. I had a lot of trouble with subqueries when I first started databases with MySQL. So I have been afraid of them.

update entities
set customer_status = select(customer_status from entity_dimension_update where entities.entity_id = entity_dimension_update.entity_id);

What a peculiar way to write a subquery, with the braces like that. Normally you'd put the opening brace before the select statement, not after it.

 Worked almost instantly.

Alternatively you could use UPDATE...FROM:

update entities
set customer_status = t2.customer_status
from entity_dimension_update as t2
where entity_id = t2.entity_id

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:737,49ed0151129747011493647!



--
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