Thread: select count(*) from : 0 rows or 1 rows ?

select count(*) from : 0 rows or 1 rows ?

From
Oleg Bartunov
Date:
discovery=> select count(*) from publications;
count
-----   0
(1 row)
 Does 1 rows is a correct result ?
Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83



Re: [HACKERS] select count(*) from : 0 rows or 1 rows ?

From
"D'Arcy" "J.M." Cain
Date:
Thus spake Oleg Bartunov
> discovery=> select count(*) from publications;
> count
> -----
>     0
> (1 row)
> 
>   Does 1 rows is a correct result ?

Absolutely.  "SELECT COUNT(*)..." always returns exactly one row (well,
assuming that the table exists, of course) so this is correct.  A return
of zero rows would imply that no information was returned but you did
get back information here, the fact that the table is empty.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 424 2871     (DoD#0082)    (eNTP)   |  what's for dinner.


Re: [HACKERS] select count(*) from : 0 rows or 1 rows ?

From
Bruce Momjian
Date:
> discovery=> select count(*) from publications;
> count
> -----
>     0
> (1 row)
> 
>   Does 1 rows is a correct result ?
> 
>     Oleg

One row is returned, and that row is zero.  It is correct.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026