complex query
Posted: Wed Oct 17, 2007 5:35 pm
Ok let me just explain what this is meant to do ... its not working but i've not done such a complex query before.
The idea of this is, the query is meant to find only the field "businesstype" where by the field is used only less than 3 times in the table... an example:
bacon
bacon
bacon
cheese
sausage
cheese
cheese
As you can see only sausage is used less than 3 times so sausage will show when I echo it... but at the moment it won't do it..any help is much appreciated.
Code: Select all
$CountNames = ("SELECT *, count(BusinessType) as C FROM `businesses` GROUP BY BusinessType HAVING C < 3");
$findbusinessresult = @mysql_query($CountNames) or die(mysql_error());bacon
bacon
bacon
cheese
sausage
cheese
cheese
As you can see only sausage is used less than 3 times so sausage will show when I echo it... but at the moment it won't do it..any help is much appreciated.