Hello,
I am trying to get statistics off my database and present it in a nice format. I have the following table (simplified version):
ProductID | ProductName | ProductHits
So there are many products there which have unique IDs and some have the same name. Now I calculate the "hits" each product gets to make a list of the most popular Products. Problem is, that it will display multiple productnames more than once (there are some different charactaristcs that each one has which I wont get into). So I was trying to remove the duplicates and show just one of each product. I had the following SQL:
mysql_query("SELECT Sum(ProductHits) AS TotalHits, ProductName FROM Products GROUP BY ProductName HAVING (ProductName=ProductName) ORDER BY Sum(ProductHits) DESC LIMIT 0,10",$db);
Not to mention that it doesnt work (do you know what's wrong with it?), but I also need it to attach a ProductID to the output. It doesnt really matter which ID it uses, but I want to see a ProductID, is that possible?