在做SSM的订单查询功能时总是报出SQL语法错误的信息,我寻思我这不是用的MyBatis给我生成的Mapper吗?怎么会有语法错误,又是一番挣扎,终于发现是因为我使用了mysql的保留字status作为我订单状态的数据库字段,保留字:
后面再试,还是同样的错误,然后又发现我又使用了保留字order作为我的表名,保留字:
真是欲哭无泪啊......
所以以后建表选字段时一定要参考着保留字来选,不要与其重名了。
若仍然想使用此字段,可以在字段前加上 ` (数字1左边的单引号)。