$CountNames = ("SELECT *, count(BusinessType) as C FROM `businesses` GROUP BY BusinessType HAVING C < 3");
$findbusinessresult = @mysql_query($CountNames) or die(mysql_error());
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.
That won't work because at the time the query is selecting what to include, it hasn't yet seen all the rows, so it doesn't have any way to know what the count will be when it is finished. At least, I think that's the case. You need to write a compound query, probably something like: