List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:November 23 1999 9:33pm
Subject:Re: Simple COUNT() statement
View as plain text  
At 5:07 PM -0400 11/23/99, Anthony Cooke wrote:
>Hello there,
>
>I'd like to have the COUNT(*) statement return the number of records that
>are returned in a simple SELECT statement with a WHERE clause. For instance:
>
>SELECT  my_idno, my_title_string, my_category FROM thetable
>     WHERE title_string LIKE "cowboy %" LIMIT 20
>
>Returns the first 20 records to fill the query.  Then:
>
>SELECT  COUNT(*) FROM thetable  WHERE my_title_string LIKE "cowboy %"
>
>Returns the number of records that qualify.
>
>I'd like to mix both select statements into one, but I've had no luck. When
>I place a GROUP BY clause, the COUNT(*) returns the size of each individual
>group... but what is required is the number of records from all groups.
>SUM(COUNT(*)) isn't allowed, either.
>
>SELECT my_idno, my_title_string, my_category, count(null) FROM thetable
>     WHERE title_string LIKE "cowboy %" GROUP BY (null) LIMIT 20
>
>Returns only the first record, although the number of counted records is
>correct.
>
>Any ideas??


You must run two queries.

-- 
Paul DuBois, paul@stripped
Thread
Simple COUNT() statementAnthony Cooke24 Nov
  • Re: Simple COUNT() statementPaul DuBois24 Nov