-
1. Re: Beginner: Getting syntax error on WHERE clause in SELECT
SnakEyez02 Oct 5, 2011 7:29 AM (in response to TCarp)Even though you don't state the exact error what I'm seeing is an issue with the order. The WHERE clause needs to be defined before the ORDER BY clause. Think of it this way, why would you want to organize and order an entire table if the WHERE clause will eliminate 95% of the results?
-
2. Re: Beginner: Getting syntax error on WHERE clause in SELECT
TCarp Oct 5, 2011 8:14 AM (in response to SnakEyez02)Thanks. Make sense but changing that didn't help.
Here's the error message I'm getting:
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='Community' ORDER BY tblmaps.DispSeq LIMIT 0, 10' at line 1
The full select (from a debugging ECHO I inserted) is:
SELECT * FROM tblmaps WHERE Group='Community' ORDER BY tblmaps.DispSeq LIMIT 0, 10
Note that when I take the WHERE clause out, there is no syntax error.
-
3. Re: Beginner: Getting syntax error on WHERE clause in SELECT
TCarp Oct 6, 2011 5:52 AM (in response to TCarp)Still can't find the error. Removed the LIMIT to see what would happen. No change.
The only thing I find strange is the "line 1" at the end of the error message. The SELECT is not on line 1 of the code.
-
4. Re: Beginner: Getting syntax error on WHERE clause in SELECT
bregent Oct 6, 2011 10:50 AM (in response to TCarp)Group is a reserved word in MySQL. You could probably put single quotes around it, but I would suggest renaming that column. You should never use reserved words for column names.
-
5. Re: Beginner: Getting syntax error on WHERE clause in SELECT
TCarp Oct 8, 2011 5:48 AM (in response to bregent)Thank you!!!!!
It looks like that was it. I changed the column name and no longer get the syntax error.
I'll be checking whether the WHERE does what I want as I complete the coding, but, for now, it looks like I learned an important lesson.
Tom


