Gossamer Forum
Home : General : Databases and SQL :

number of records in table

Quote Reply
number of records in table
Ok, this may seem like another dumb question from Sooke, but there seems to be many ways of doing this. (select, count or otherwise)

What is the most efficient way to set a value equal to the number of rows (including nulls) in a table?

Example my $total_categories = $DB->table('Category') blah

and one more thing.... how easy is it to add the "DISTINCT" value to such a count if need be?

Many thanks.

Last edited by:

sooke: May 15, 2002, 4:38 PM
Quote Reply
Re: [sooke] number of records in table In reply to
# Normal count
my $total = $DB->table('Table')->count;

# Distinct
my $total = $DB->table('Table')->select( 'DISTINCT(Column)' )->rows;
Quote Reply
Re: [Paul] number of records in table In reply to
Just added that to my box of tricks. Thanks Paul.


http://www.iuni.com/...tware/web/index.html
Links Plugins