| From: | CSN <cool_screen_name90001(at)yahoo(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | more than one row returned by a subquery used as an expression |
| Date: | 2005-10-14 00:05:56 |
| Message-ID: | 20051014000556.10102.qmail@web52904.mail.yahoo.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Guy Rouillier | 2005-10-14 00:17:46 | Re: PostgreSQL's bug tracker |
| Previous Message | Bruce Momjian | 2005-10-13 23:09:24 | Re: [GENERAL] binary timestamp conversion |