Search Postgresql Archives

Re: select count(*);

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Marc Mamin <M.Mamin@xxxxxxxxxxxx> writes:
>> The * might be a bit tricky, though,
>> since 'select *;' doesn't work.

> That's the point. * has no meaning without FROM

PG regards "count(*)" as a weird spelling of "count()", ie, invoke an
aggregate that takes no arguments.  It really doesn't have anything to do
with the meaning of "*" as a SELECT-list item, any more than it does with
the meaning of "*" as multiplication, say.  It's just syntax that's
written like that because the SQL standard says we have to.

Another way of making the point is that SELECT without a FROM list can
be seen as implicitly selecting from a dummy table with one row and no
columns.  Some other systems such as Oracle make you do that explicitly,
ie the infamous "FROM dual" hack; there's nothing in the SQL standard
saying you can omit FROM.  If you suppose that that's the underlying model
then the result of "select count(*)" is completely natural.

			regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux