How to escape apostrophe (') in MySql?

前端 未结 10 654
孤城傲影
孤城傲影 2020-11-22 07:49

The MySQL documentation says that it should be \\\'. However, both scite and mysql shows that \'\' works. I saw that and it works. What should I d

10条回答
  •  太阳男子
    2020-11-22 08:27

    Replace the string

    value = value.replace(/'/g, "\\'");
    

    where value is your string which is going to store in your Database.

    Further,

    NPM package for this, you can have look into it

    https://www.npmjs.com/package/mysql-apostrophe

提交回复
热议问题