trivial sql help

From: Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: trivial sql help
Date: 2002-10-10 15:52:00
Message-ID: 20021010165200.O6842@quartz.newn.cam.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm afraid I can't spot my error anymore... Any hints?

select pc.c,count(pc.c)
from rawrequest,pers_comp as pc
where pc.p=pid
group by pc.c
having count(pc.c)=1
;

c | count
-----+-------
16 | 1
38 | 1
59 | 1
63 | 1
83 | 1
89 | 1
128 | 1
138 | 1
146 | 1
154 | 1
156 | 1
158 | 1
203 | 1
204 | 1
221 | 1
257 | 1
314 | 1
333 | 1
(18 rows)

update rawrequest
set cid=(select pc.c
from pers_comp as pc
where pc.p=pid
group by pc.c
having count(pc.c)=1
)
where pr
;

ERROR: More than one tuple returned by a subselect used as an expression.

pid, pc.p, pc.c, cid are all integers. pc just has 2 columns p and c.

I thought putting the count()=1 in there would force a single tuple..

Cheers,

Patrick

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Erwan DUROSELLE 2002-10-10 15:58:01 Rép. : Re: access time performance problem
Previous Message Michael Kichanov 2002-10-10 15:43:06 Re: connection watchdog