Re: Help with mysql query

From: Date: Tue, 11 Dec 2001 23:44:56 +0000
Subject: Re: Help with mysql query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-77380@lists.php.net to get a copy of this message
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" <d@mindbash.com> To: "PHP" <php-general@lists.php.net> 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 # > # d@mindbash.com | +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: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#77380) next »