trivial sql help

Поиск
Список
Период
Сортировка
Искать
От
Patrick Welche
Тема
trivial sql help
Дата
Msg-id
20021010165200.O6842@quartz.newn.cam.ac.uk
Список
Дерево обсуждения
Re: trivial sql help Joe Conway <mail@joeconway.com>
Re: trivial sql help Patrick Welche <prlw1@newn.cam.ac.uk>
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 по дате отправления
От: scott.marlowe
Дата:
От: Erwan DUROSELLE
Дата:
FAQ