At 1:40 PM -0400 09-11-2000, Lee Nelson wrote:
>Hi Everyone,
>
> I've been developing an application around MySQL for the
>past few months, and so far it's been a joy to use.
>
> However, I am having some difficulty constructing a query,
>and hoped that you folks might be able to help.
>
> I am using a web form to construct a query on the database.
>I wish to show the users how many hits they will get, without
>actually pulling all the data across the link and counting it
>(there are several hundred thousand rows).
>
> For most cases:
>
> SELECT count(*) FROM data where (user_criteria)
>
> works perfectly. However, one of the query items is
>"unique EINs". for which I would normally construct the
>query as:
>
> SELECT ein, d1, d2, d4, etc from data
> where (user_criteria) group by ein;
>
> But of course if I try to say
>
> SELECT count(*) from data
> where (user_criteria) group by ein;
>
> I just get a large number of counts, instead of a
>single count.
>
> Is there any way to count the results of a SELECT
>query that includes a GROUP BY clause?
This doesn't do what you want?
SELECT COUNT(*), ein from data where (user_criteria) group by ein;
That gives you a count of each ein value in the result set,
one row per value.
--
Paul DuBois, paul@stripped