Error when intellij integrates mybatis query

created at 09-09-2021 views: 2

sql syntax error,

Paste the generated code into sqlyog and run it, which also raises the error

The reason is that sql keywords, such as lock, are used in sql.

from tbl_admin
    where id = 1' at line 3
### The error may exist in file [D:\OneDrive\project\activiti\target\classes\mapper\AdminMapper.xml]
### The error may involve cn.taotao.dao.AdminMapper.selectByPrimaryKey-Inline
### The error occurred while setting parameters
### SQL: select            id, username, password, email, lock, birth         from tbl_admin     where id = ?
### Cause: java.sql.SQLSyntaxErrorException: 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 'lock, birth

    from tbl_admin
    where id = 1' at line 3
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: 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 'lock, birth

solution

The error has already mentioned near ‘lock ,birth, from tbl_admin where id =1'.....

The reason for the error here is that lock is a keyword, just change it to something else. Did it for half an afternoon

created at:09-09-2021
edited at: 09-09-2021: