FoxRocks Posted September 25, 2012 Share Posted September 25, 2012 (edited) Hello, I'm trying to do a simple database query and I keep getting an error saying: 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 'group='sales'' at line 1 I am absolutely stumped, I have used this exact syntax before and it worked just fine! and it works perfectly if I take out that one section group='sales' Here is my code: $result = mysql_query("SELECT * FROM faq WHERE group='sales' "); I have a table, named faq with four columns in it...id, question, answer, group. I have checked to make sure I have data in the table and that all the spelling is correct and everything checks out. I have one entry in the "group" column that has "sales" in it and I'm trying to retrieve the "questions" and "answers" for a simple FAQ page. BTW, I realize this is a PHP form and I'm asking about Mysql syntax, I hope that's alright? Also, if I left something out please just let me know and I'll get right back to you. Thank you SO much for any direction or help you can give me, I'm at a complete loss!! ~FOX~ Edited September 25, 2012 by FoxRocks Quote Link to comment https://forums.phpfreaks.com/topic/268773-mysql-where-syntax-help/ Share on other sites More sharing options...
Barand Posted September 25, 2012 Share Posted September 25, 2012 GROUP is a reserved word in MySQL. Either rename the column or use `group` (with backticks) in your queries Quote Link to comment https://forums.phpfreaks.com/topic/268773-mysql-where-syntax-help/#findComment-1380770 Share on other sites More sharing options...
FoxRocks Posted September 25, 2012 Author Share Posted September 25, 2012 YYEESSS!!!!! Thank you so much!!! I obviously learned a valuable lesson today, I can't thank you enough Quote Link to comment https://forums.phpfreaks.com/topic/268773-mysql-where-syntax-help/#findComment-1380773 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.