Jump to content

[SOLVED] SELECT DISTINCT and COUNT


scarhand

Recommended Posts

I am trying to output distinct band names, but count the amount of rows they take up in the database

 

this is not working:

 

  $sql = mysql_query("SELECT DISTINCT(band), COUNT(band) as count FROM tabs WHERE band LIKE '$letter%' LIMIT 100");
  
  while ($row = mysql_fetch_array($sql))
  {
    $band = $row["band"];
    $count = $row["count"];
    
    echo "$band - $count<br>";
  }

 

any help is appreciated

Link to comment
https://forums.phpfreaks.com/topic/131319-solved-select-distinct-and-count/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.