How to return distinct values and their count?

What I'm trying to do is (hopefully) simple, but I just don't quite have the right syntax. I'd like to return all distinct values in a table with a count of how many records for each value.

So, in PHP, I've got:

$result = mysql_query("SELECT DISTINCT tagName FROM tagTable");
while($row = mysql_fetch_array($result)){
    echo("<p>" . $row['tagName']) . "</p>");

This works well. The distinct values are returned! But now how do I get each distinct value's count to display as well? I would want something to the effect of:

echo("<p>" . $row['tagName']) . $tagCountGoesHere . "</p>");


You should be able to get that using the GROUP BY clause:

SELECT tagName, count(tagName) AS tagCount FROM tagTable GROUP BY tagName

Need Your Help

Specific Instructions on Building POCO under C++ express

c++ windows visual-studio-2010 visual-studio poco-libraries

Searching around stackoverflow, I found out that the POCO library build file is not compatible with Visual Studio Express, that it needs devenv.exe. Some answeres say to replace devenv with vcexpre...

Syntax error in for loop (Ruby/RSpec)

ruby rspec

While running the RSPEC test as shown below im getting this error:

Combine UITabBarController with UINavigationController

iphone objective-c ios xcode cocoa-touch

I tried to use an "tabbed application" with a navigation bar in it. With the default the tab bar works fine, but I just can't gat a navigation bar. I found some stuff about pushing the navigation-b...