mysql 表中字段插入含有特殊符号:
insert into a values(3,\[\["1312","1321"\]\]);
ERROR 1064 (42000): 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 '1312","1321"\]\]")' at line 1
解决方法:加单引号
insert into a values(4,'[["1312","1313","1314"]]');
insert into a values(4,'***********"1312","1313","1314"*****');
select * from a;
+------+--------------------------------------+
| id | name |
+------+--------------------------------------+
| 2 | game2 |
| 4 | [["1312","1313","1314"]] |
| 4 | ***********"1312","1313","1314"***** |
+------+--------------------------------------+
insert into a values(3,\[\["1312","1321"\]\]);
ERROR 1064 (42000): 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 '1312","1321"\]\]")' at line 1
解决方法:加单引号
insert into a values(4,'[["1312","1313","1314"]]');
insert into a values(4,'***********"1312","1313","1314"*****');
select * from a;
+------+--------------------------------------+
| id | name |
+------+--------------------------------------+
| 2 | game2 |
| 4 | [["1312","1313","1314"]] |
| 4 | ***********"1312","1313","1314"***** |
+------+--------------------------------------+
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30162734/viewspace-2152774/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30162734/viewspace-2152774/
本文介绍在MySQL中如何正确地插入包含特殊字符的数据。通过对比错误的SQL语法与正确的写法,帮助读者理解如何使用单引号正确转义字符串中的特殊字符。
2304

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



