Jump to content

sql count statement - this is probably really simple


peehaichpee

Recommended Posts

I'm trying to work out a count of how many of what assets are in a certain location:

there should be 13 different categories (asset types) in a location and i want the individual count of each category. here's what i have - which seems to give me a total count of all assets and locations together plus one asset description and one location.....

almost right.

 

$con = mysql_connect('localhost','root','');
  if(! $con) die(mysql_error()); 
mysql_select_db("test",$con);
$result = mysql_query("SELECT DISTINCT COUNT(`Asset Description`) AS TOTALAD, LOCATION, `Asset Description` AS AD FROM master WHERE LOCATION like 'NC%'");



while($row = mysql_fetch_array($result))
  {
  echo $row["LOCATION"];
   echo "<br />";
  echo $row["TOTALAD"];
   echo "<br />";
  echo $row["AD"];
  echo "<br />";
  }
mysql_close($con);

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.