I can get a count of the number of times each element occurs using the following MySQL
SELECT COUNT(*) AS count
FROM example
GROUP BY example.value
The problem is, because of the GROUP BY statement, duplicate records will not be returned with their COUNT value.
IE I need this:
- apples - 2
- apples - 2
- oranges - 1
- bananas - 3
- bananas - 3
- bananas - 3
But I get this:
- apples - 2
- oranges - 1
- bananas - 3
Any ideas how this could be done? I am thinking some kind of a join, but I can't figure out the proper way to compare the table to itself