sql語句中詞和mysql的關鍵字沖突了,用 `` (tab鍵上方)將詞括起來就好了。
原來的sql語句
1
2
3
4
5
6
7
|
< insert id= "insert" parameterType= "com.zhangman.manman.entity.User" > insert into user (id, username, password , name , desc ,email,birthday,phone,status,createtime,roleId) values (#{id,jdbcType= INTEGER }, #{username,jdbcType= VARCHAR }, #{ password ,jdbcType= VARCHAR }, #{ name ,jdbcType= VARCHAR }, #{ desc ,jdbcType= VARCHAR }, #{email,jdbcType= VARCHAR }, #{birthday,jdbcType= VARCHAR }, #{phone,jdbcType= VARCHAR }, #{status,jdbcType= INTEGER }, #{createtime,jdbcType= DATE }, #{roleid,jdbcType= INTEGER }) </ insert > |
改正后的 sql(注意,字段和表名都用``括起來了)
1
2
3
4
5
6
7
|
< insert id= "insert" parameterType= "com.zhangman.manman.entity.User" > INSERT INTO ` user ` (username, ` password `,` name `,` desc `,email,birthday,phone,`status`,createtime,roleId) VALUES (#{username}, #{ password },#{ name }, #{ desc },#{email}, #{birthday}, #{phone}, #{status}, #{createtime}, #{roleid}) </ insert > |
補充:MySql ERROR 1064 (42000)同樣的錯誤,不一樣的解決方法
開始時代碼是這樣:
然后運行:
代碼根本毫無錯誤,但為什么會出錯呢?在我花了2個小時后終于知道了答案。
我沒有加分號!!!!!
修改后代碼:
然后再次運行后:
再一次為自己的無知和粗心感到絕望!!!
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持服務器之家。如有錯誤或未考慮完全的地方,望不吝賜教。
原文鏈接:https://blog.csdn.net/zm9898/article/details/89526555