Re: How to count same text results from DB?
| From: | Vojtech Dvorak | Date: | Tue, 03 Oct 2000 09:44:53 +0000 |
| Subject: | Re: How to count same text results from DB? | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-3253@lists.php.net to get a copy of this message | ||
Yes I know...
+++
SELECT name, COUNT(*)
FROM users
WHERE age=18
GROUP BY name
+++
but as I said I need only one select for whole page and I am getting more
than this from this select.
my original SELECT is now:
+++
SELECT name, class, age, descr, tech, local
FROM users
WHERE class=3A
+++
So I am getting bunch of data and when I want to do GROUP BY I have to use
another SELECT.... and than it is too slow...
It must be way how to count it with help of PHP.
Thanks
Vojtech
> hi,
>
> try GROUP BY
>
>
>
>
> Hi,
> I have made select such as
> SELECT name, age
> FROM users
> WHERE age=18
>
> I need to have at final something like:
> There is 27 Johns, 30 Pauls, 13 Marks etc.
>
> But few problems to make it harder:
> 1) I can't use more than one select, because this database is very slow
(M$
> Access)
> 2) I don't know names in database (in that case I would make If
$name==John
> {$john++} clauses)
>
> I was thinking about fetching all names in array and than count it
> somehow....
> Please PHP Gurus help.
> Thx
> Vojtech
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>