Say you are writing a new stored procedure (for MySQL) and when you execute it, you get an error something like shown below - as you probably figured out all it means is that there is a syntax error with in the SQL. Often the error is misleading especially if it is a complicated query. One easy way to help narrow down the issue is to run it in a SQL Console which usually provides a better clue that can be your pointer to fixing the issue.
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 ‘END’ at line 17 (errno: 1064). Click ‘Ignore’ if you’d like to have this error ignored until the end of the script.
If you run this script you will get the above error:
|
|
The main issue in my example above was that a delimiter (semi-colon in this case) was missing where the SQL statement finishes i.e. in the last WHERE condition. Here is a snippet of what the updated WHERE clause should look like.