Tag Archives: SQLSyntaxErrorException: You have an error in your SQL syntax;

Treatment of MySQL database keyword as column name by mybatisplus — sqlsyntax errorexception: you have an error in your SQL syntax;

explain:

When designing the database, if you use the MySQL keyword as the column name (for example, order is used for sorting), an error will be reported: java.sql.sqlsyntax errorexception: 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 ‘ORDER,CREATE_ TIME,MODIFY_ TIME FROM xxx’ at line 1

terms of settlement:

Modify the column name, do not use the keyword as the column name; (recommended)

When querying, use quotation marks (single quotation marks, double quotation marks and back quotation marks) to enclose the column name of its keyword,

If you use mybatis to write SQL, there is no problem. You can use quotation marks to solve it;

If you use mybatis plus, when querying all columns, you need to list all columns, because the corresponding column names containing keywords need to be processed.