When executing a query in SQL and the editor throws back this error:

Incorrect syntax near …''

That typically means you have used the wrong syntax for the query. This happens mostly when someone switched from one relational database to another relational database, from MySQL to MS SQL Server for example. Even though SQL is standard, each database management system has it own extensions thus the syntax might vary.

So the solution is to search for the right query and replace it.

But there are some cases where the syntax seems correct, but you still keep getting the incorrect syntax error above?

This one is tricky. Such unexpected syntax error sometimes happens when you copy and paste the query directly from another source, such as from a website or note-taking app. The text then contains invisible characters like individual CR or LF and non-breaking spaces.


  • Paste it to TextEdit or Notepad to identify the invisible characters and remove them.
  • Use the Beautify button in TablePlus to reformat the code and TablePlus will automatically remove the unwanted non-standard characters.


Need a good GUI tool for databases? TablePlus provides a native client that allows you to access and manage Oracle, MySQL, SQL Server, PostgreSQL, and many other databases simultaneously using an intuitive and powerful graphical interface.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

On Linux? Download TablePlus for Linux

Need a quick edit on the go? Download TablePlus for iOS

TablePlus in Dark mode