Thread: Getting the result of a query using COUNT(*)

Getting the result of a query using COUNT(*)

From
"Jackson Ching"
Date:
Hi,

    I'm using JSDK 2.0 and IBM JDK 1.3 on RedHat Linux 6.2

    As i test my servlet,  I got errors saying count(*) column not found in a query like this

    SELECT COUNT(*) FROM MyTable

    in my rs.getint("COUNT(*)");   in oracle it works fine, in postgresql it doesn't. how should i handle aggregate
functionsin SQL then? 

    Thanks

Jackson


Re: Getting the result of a query using COUNT(*)

From
Tom Lane
Date:
"Jackson Ching" <jching@imvi.com.ph> writes:
>     SELECT COUNT(*) FROM MyTable

>     in my rs.getint("COUNT(*)");

Offhand I'd guess that the returned column heading is "count" not
"COUNT(*)".  Use an AS clause if you want to be sure about the
column heading of a SELECT result...

            regards, tom lane