Any ideas why this isn't working: SELECT `Item Type`, COUNT(*), FROM Stock WHERE `Use Commenced By` = "" GROUP BY `Item Type` Code (markup): But this works fine: SELECT `Item Type`, COUNT(*), FROM Stock GROUP BY `Item Type` Code (markup):
Just get this Error[/B] [B]SQL query: [IMG]https://p3nlmysqladm001.secureserver.net/nld50/85/themes/original/img/b_help.png[/IMG] SELECT `Item Type` , COUNT( * ) , FROM Stock WHERE 'Use Commenced By' = "" GROUP BY `Item Type` LIMIT 0 , 30 MySQL said: [IMG]https://p3nlmysqladm001.secureserver.net/nld50/85/themes/original/img/b_help.png[/IMG] #1064 - 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 'FROM Stock WHERE 'Use Commenced By' = "" GROUP BY `Item Type` LIMIT 0, 30' at line 4 Code (markup):
I created a fiddle - works there http://sqlfiddle.com/#!9/f8474/2 Maybe you could set up one with a sample of your tables and real data for us to test.
If that's what you get, whatever you're using to run that query "fixes" the quotes. Use another method / program / whatever.
One thing I would advise against is using spaces in field names. Instead the better way is to use Camel Cased or Lower Case for the titles: Item_Type/item_type Use_Commenced_By/use_commenced_by I am not saying that it is wrong to have spaces, just not the norm. Other than that the original statement is fine, you use backticks to escape the column name in where not single quotes. Are you sure that the result set you are expecting exist? Also remove the comma after the last field you want count() as it is not needed.