问题
I have a table with two fields, TAG_ID and TAG_DESC
my primary is tag_id.
I'm looking for a query that will display each TAG_DESC and the amount of times it occurs next to it.
Thanks,
回答1:
SELECT TAG_DESC as 'Description',
COUNT(TAG_DESC) as 'Occurances'
FROM table_name
GROUP BY TAG_DESC
回答2:
select TAG_DESC, count(*)
from MyTable
group by TAG_DESC
来源:https://stackoverflow.com/questions/3808062/counting-mysql-values