How to escape apostrophe (') in MySql?

前端 未结 10 750
孤城傲影
孤城傲影 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:31

    There are three ways I am aware of. The first not being the prettiest and the second being the common way in most programming languages:

    1. Use another single quote: 'I mustn''t sin!'
    2. Use the escape character \ before the single quote': 'I mustn\'t sin!'
    3. Use double quotes to enclose string instead of single quotes: "I mustn't sin!"

提交回复
热议问题