BioBob Posted October 25, 2010 Share Posted October 25, 2010 Its a fairly stright forward question I think. Lets say I have an Enum or a Set type, where I specify the specific values of the Set. Say the field is called Fruits. If I want to have more different types of Fruits available later, I can edit and add those new fruits to the set type later. So lets say for right now I have Apples, Oranges, and Bananas. In my php code, I could hard set these values, but I want to count the total number of different values, or simply return the values themselves. I'll be happy with either an INT for returning a COUNT(*) or the Value, IE mysql_fetch returns (Apples, Oranges, Bananas), so either way. The total number probably isn't going to be a very high number, single digits, maybe low double digits... How on earth would I do that? Link to comment https://forums.phpfreaks.com/topic/216816-mysql-how-do-i-count-the-total-number-of-different-enum-set-types/ Share on other sites More sharing options...
kai555 Posted October 26, 2010 Share Posted October 26, 2010 Hi I assume you have each type of fruit more than once in your table? I think what you are looking for is: SELECT COUNT(DISTINCT column_name) as c FROM table_name Link to comment https://forums.phpfreaks.com/topic/216816-mysql-how-do-i-count-the-total-number-of-different-enum-set-types/#findComment-1126610 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.