Search Postgresql Archives

more than one row returned by a subquery used as an expression

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

 



I'm trying to get this query to work:

update sectors set companies =(select companies from
industries where sector_id =sectors.id);

PG returns:

ERROR:  more than one row returned by a subquery used
as an expression

Column companies is just a count of rows in the
related companies table. Queries like this worked:

update industries set companies =(select count(id)
from companies where industry_id =industries.id);

I know I could do a join in the subselect, but I'm
curious why this doesn't work. If I do the subselect
by itself, it looks like all of the rows from the
industries table are return (I expected an error). Is
this the "implicit FROM" gotcha?

CSN


		
__________________________________ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

[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