Daniel,

Try this.  Still sort of a brute force method but just 10 query strings
instead of 50 but nothing MySQL is going to balk at.

<?php
$num_vals = array ();
for ($i=0; $i<10; $i++)
{
  $query = "SELECT * FROM my_table WHERE 1 = '$i' || 2 = '$i' || 3 = '$i' ||
4 = '$i' || 5 = '$i'";
  $result = mysql_query ("$query", $db);
  $num_vals[$i] = mysql_num_rows($reslut);
}
?>

Then you an print out the results stored in the $num_vals list using a
similar for loop.

-Kevin Stone


----- Original Message -----
From: "Daniel AlsÚn" <[EMAIL PROTECTED]>
To: "PHP" <[EMAIL PROTECTED]>
Sent: Tuesday, December 11, 2001 4:09 PM
Subject: [PHP] Help with mysql query


> Even if this isn┤t a mysql forum i hope to get some help on this:
>
> I have a table with 5 columns (named one to five) which contains numerical
> values between 1 and 10.
> I am trying to construct a query that gives me the count of the
> representation of each numerical value (ie how many fives that are
stored).
>
> Can i do this in a smart way without having to write fifty queries and add
> every fifth of them up?
>
> Regards
> # Daniel AlsÚn    | www.mindbash.com #
> # [EMAIL PROTECTED]  | +46 704 86 14 92 #
> # ICQ: 63006462   | +46 8 694 82 22  #
> # PGP: http://www.mindbash.com/pgp/  #
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to