The MySQL SQL Error 1064 Blues
Writing error messages is an art. Sadly, most of us lack talent in that area. One of the prime examples that you see with SQL User Interfaces is the MySQL SQL Error 1064. SQL Error [1064] [42000]: 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 'select @var' at line 2 Error position: line: 1 Explicit and clear, it ain't. I am using DBeaver for this example, but the issue can be reproduced on MySQL Workbench, Toad, and many other tools. In the following, an environment variable is set on the first line, and then a SELECT is used to return that variable. However, we receive a response of 1064. So what happened? While both lines were input to the console, only the second line was executed. When we ask the server about @var, it has no knowledge of it and replies with the 1064 Error. "But we typed it in!" Yeah, we typed it in, but the set was not e...