How do I insert a special character such as ' into MySQL? -
i executing insert
query shell script reads data multiple files. of data inserted contains '
in text , mysql keeps giving errors
error 1064 (42000) @ line 1: have error in sql syntax; check manual corresponds mysql server version right syntax use near 's development & empowerment, youth affairs ',' himachal pradesh ' @ line 1
this actual text: women's development & empowerment, youth affairs
.
you need escape quote, so:
'women\'s development & empowerment, youth affairs'
note, if you're generating sql statement language php, there functions available you.
in php, instance, there mysql_real_escape_string, takes care of you. note, prepared statements prefered on this, it's harder wrong.
see also:
Comments
Post a Comment