Hi Andy, > I am wondering if it would be possible to get the amount of different values > in one sql command. > E.g.: > field age: 0,3,5,5,2,3 > > Sql querry should return how often 3 occurs. Which would be 2. And as well > the other values... 1 for agestructure 2 becuase it occures only once. > > I wrote following querry > > $stmt=" > SELECT COUNT(*) AS c > FROM $T5 > WHERE age = 4 > "; > $row = db_get_row2($stmt); > $age_4 = $row->c; > > This returns only the value for 4. To get all values (10 different ones) I > would have to make 10 querrys, right? > > Is there a faster way?
SELECT COUNT( IF( age = 0, 1, 0 ) ) AS Infants, COUNT( IF( age = 1, 1, 0 ) ) AS One, COUNT( IF( age = 2, 1, 0 ) ) AS Two, ... FROM $T5; but at this time of night, shouldn't you be counting sheep? =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php