Re: selecting count and then dumping to an array
| From: | Jim Lucas | Date: | Sat, 07 Jun 2003 15:06:59 +0000 |
| Subject: | Re: selecting count and then dumping to an array | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-150584@lists.php.net to get a copy of this message | ||
building on the only reply that I saw try this also.
Say you had 12 different TYPE's that are in your table, and you only wanted
5 of them.
Then you will want something like what follows.
SELECT type, count(*) FROM table WHERE type='$1' OR type='$2' OR \
type='$3' OR type='$4' OR type='$5' GROUP BY
type;
another way you can write this is like the following,
but it won't take advantage of indices
SELECT type, count(*) FROM table WHERE type IN ('$1', '$2', '$3',
'$4',
'$5') GROUP BY type;
Jim Lucas
----- Original Message -----
From: "Ryan A" <ryan@jumac.com>
To: <php-general@lists.php.net>
Sent: Saturday, June 07, 2003 8:53 AM
Subject: Re: [PHP] selecting count and then dumping to an array
> Thanks guys,
> will give it a shot and write back if i have any problems.
> Cheers,
> -Ryan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>