Jump to content

sql count statement - this is probably really simple


peehaichpee
 Share

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);

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.