trivial sql help - Mailing list pgsql-general

From Patrick Welche
Subject trivial sql help
Date
Msg-id 20021010165200.O6842@quartz.newn.cam.ac.uk
Whole thread Raw
Responses Re: trivial sql help  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List 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

pgsql-general by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: access time performance problem
Next
From: "Erwan DUROSELLE"
Date:
Subject: Rép. : Re: access time performance problem