org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: 关键字 'user' 附近有语法错误。
### The error may exist in zzu/qg/mybatis/mapper/user.xml
### The error may involve zzu.qg.mybatis.mapper.findUserById-Inline
### The error occurred while setting parameters
### SQL: select * from user where id = ?
### Cause: com.microsoft.sqlserver.jdbc.SQLServerException: 关键字 'user' 附近有语法错误。
sql Server中user是关键字,
所以,在写查询语句的时候要在user上加[ ]
select * from [user] from where id=1
之前也遇到过,报的错误是:关键字'order'附近有语法错误 order也是关键字
本文详细解析了在SQLServer中使用保留关键字作为表名或字段名时遇到的语法错误问题,如关键字'user'和'order'附近的语法错误。通过在关键字周围加上方括号[],可以有效解决此类问题,确保SQL查询语句的正确执行。
1万+

被折叠的 条评论
为什么被折叠?



