db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Eade <se...@backstagetech.com.au>
Subject Re: Count(*) and criteria
Date Sun, 02 Feb 2003 22:15:37 GMT
Try something like:

Criteria c = new Criteria();
c.addSelectColumn("COUNT(" + colName + ")");
List result = doSelect();
Record rec = (Record) result.get(0);
int count = rec.getValue(1).asInt();

Where colName is the name of some small column in the table (can't remember
why, but "*" doesn't work when the query is done this way).

BTW: Have you looked at LargeSelect?


Scott Eade
Backstage Technologies Pty. Ltd.
.Mac Chat/AIM: seade at mac dot com

On 3/02/2003 4:16 AM, "peter riegersperger" <rick@subnet.at> wrote:

> hello!
> i'm using torque as part of a turbine project, and have spent some time now
> trying to figure out something i think is fairly basic:
> i'm using paginated lists of entries (limit and offset), but i need to know
> the number of total records for the given query (without limit and offset
> set) to calculate the total number of pages.
> i don't want to run the complete query (because i don't need the records), i
> just want to get a "Count(*) from ... where ..."
> how can this be done? i've tried and read the javadoc, and the tutorials and
> the list archive, but to no avail. is the solution _that_ obvious? (i sure
> hope not ... ;)
> i'd be greatful for any help, i'm definitely completely without the slightest
> idea.
> regards,
> rick

View raw message