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

From: "D'Arcy" "J(dot)M(dot)" Cain <darcy(at)druid(dot)net>
To: oleg(at)sai(dot)msu(dot)su (Oleg Bartunov)
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] select count(*) from <empty table>: 0 rows or 1 rows ?
Date: 1999-05-31 12:29:55
Message-ID: m10oRCV-0000bIC@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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(at){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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Horak Daniel 1999-05-31 12:44:31 RE: [HACKERS] report for Win32 port
Previous Message The Hermit Hacker 1999-05-31 12:20:24 Re: [HACKERS] History of PostgreSQL