count of a value in a column in mysql database
i have a large mysql database 开发者_JAVA技巧table in which one column contains values ranging from 1 to 9 what query can i give so that i can get the count of 1s and 2s and 3s ... 9s in that column in the database ?
select column, count(*) from table group by column
You use grouping:
select TheValue, count(*)
from TheTable
group by TheValue
order by TheValue
精彩评论