我正在insert
从shell脚本执行查询,该脚本从多个文件中读取数据.要插入的一些数据包含'
在文本中,MySQL不断给出错误
ERROR 1064 (42000) at line 1: 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 's Development & Empowerment, Youth Affairs
','
Himachal Pradesh ' at line 1
Run Code Online (Sandbox Code Playgroud)
这是实际的文字:Women's Development & Empowerment, Youth Affairs
.
Seb*_*olm 16
你需要逃避报价,如下:
'Women\'s Development & Empowerment, Youth Affairs'
Run Code Online (Sandbox Code Playgroud)
请注意,如果您使用PHP等语言生成SQL语句,则可以使用一些函数来执行此操作.
例如,在PHP中,有mysql_real_escape_string,它会为您处理它.请注意,准备好的陈述应该优先考虑,因为更难弄错.
也可以看看: