Page 1 of 1

Query error..

Posted: Mon Oct 22, 2007 1:09 pm
by SirChick
I'm getting this error with my query... not sure how to fix it though....


You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE C < '3'' at line 1

Code: Select all

<?php
//generates a list box to display the rows of available houses in the soldhouses table depending on which one the user clicks on then clicks buy will be "should be" the one that goes to the session
$CountNames = ("SELECT *, count(BusinessType) as C FROM `businesses` GROUP BY BusinessType WHERE C < '3'");
$findbusinessresult = mysql_query($CountNames) or die(mysql_error());

echo '<br><br><center><select name="businesslist" size=10>">';
		Echo'<option value =""><b><u>Business Types</b></u></option>';
while($row = mysql_fetch_array($findbusinessresult)) {
        echo "<option value=\"{$row['BusinessType']}\">{$row['BusinessType']}</option>";
		}
echo '</select></center>';


?>
What did i do wrong?

Posted: Mon Oct 22, 2007 5:31 pm
by feyd
GROUP BY goes after WHERE clauses, not before.