Search code examples
mysqlescaping

How to escape apostrophe (a single quote) in MySql?


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 do?


Solution

  • Standard SQL uses doubled-up quotes; MySQL has to accept that to be reasonably compliant.

    'He said, "Don''t!"'