Forum Moderators: open
I am using php 5 & MySql 5 and i am selecting enum values from DB.
The ENUM is either 'A' or 'B'
So, is it possible to count how much A's or B's directly in the query without using php to loop and count them?
Thanks in advance
But I think you could use a sub select.
SELECT x, y, (SELECT count(ab) FROM yourtable WHERE ab = 'A') as count_A, (SELECT count(ab) FROM yourtable WHERE ab = 'B') as count_B, ...
my query is already big and has some joins, so i wouldnt add this to it!
i think i will go with this...
$sql = mysql_query("Select big query....")
while($rs = mysql_fetch_object($sql)) { if($rs->enum == "a") $count++; } mysql_data_seek($sql, 0);
or is there better solution?
Thank in advance!