October 2022
Intermediate to advanced
380 pages
9h 35m
English
In the case of SQL syntax errors, MySQL provides useful information: exactly what part of the SQL query followed the part where the syntax parser got confused or was expecting something different.
In Mini-Antipattern: Reserved Words, you saw how a query that uses a reserved keyword in an unexpected position can result in a syntax error. Other types of syntax errors can be caused by missing keywords, extra keywords, or mistakes using punctuation.
The following should use the ORDER BY syntax, but the keyword BY is missing.
| | SELECT * FROM Bugs ORDER date_reported; |
| | ^ error starts here |
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to ...
Read now
Unlock full access