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

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: CSN <cool_screen_name90001(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: more than one row returned by a subquery used as an
Date: 2005-10-14 12:57:36
Message-ID: 434FAB40.8070103@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

CSN wrote:
> I'm trying to get this query to work:
>
> update sectors set companies =(select companies from
> industries where sector_id =sectors.id);

Try these instead:

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

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

--
Alban Hertroys

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2005-10-14 13:00:34 Re: Postgres logs to syslog LOCAL0
Previous Message Rick Schumeyer 2005-10-14 12:41:06 problem converting from 8.0.4 to 8.1beta3: character encoding