项目场景:
MyBatis框架初学,在连接数据库实现增,删,改,查,时出现的一个问题.
问题描述:
org.apache.ibatis.exceptions.PersistenceException:
Cause:com.mysql.jdbc.exceptions.jdbc4.MySQlSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
在使用mapper书写SQL语句并在实现类中调用,在测试类中测试时,出现的SQL语句的错误
<mapper namespace="Mapper文件的路径">
<update id="update"> set
update idol
name=#{name},
age=#{age},
group=#{group},
position=#{position},
sex=#{sex}
where
id = #{id}
</update>
原因分析:
mysql中有一些设定好的关键字是不可以用来作为表的 列名 的否则就会在书写更新的SQL语句的时候出现上述问题.
解决方案:
解决方案就是:使用反引号 ESC下面的那个符号,引起来就可以使用了.
如果有什么不对的地方请各位大佬指正.