johnsmith153 Posted October 20, 2010 Share Posted October 20, 2010 Very simple - or I thought. Imagine simply a 'value' field which holds 13 different values from "A" to "M" (and thousands of records). I simply want to count how many of each exist. COUNT(value) FROM $table WHERE value="A" COUNT(value) FROM $table WHERE value="B" COUNT(value) FROM $table WHERE value="C" ...would do it, but surely there is a better way as I need to check all 13 at the same time. Quote Link to comment https://forums.phpfreaks.com/topic/216404-select-count/ Share on other sites More sharing options...
ram4nd Posted October 20, 2010 Share Posted October 20, 2010 php coding forum is wrong place to ask sql question Quote Link to comment https://forums.phpfreaks.com/topic/216404-select-count/#findComment-1124557 Share on other sites More sharing options...
PFMaBiSmAd Posted October 20, 2010 Share Posted October 20, 2010 SELECT COUNT(*) as cnt FROM $table GROUP BY value Quote Link to comment https://forums.phpfreaks.com/topic/216404-select-count/#findComment-1124615 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.