How to escape apostrophe (') in MySql?

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

    Here's an example:

    SELECT * FROM pubs WHERE name LIKE "%John's%"
    

    Just use double quotes to enclose the single quote.

    If you insist in using single quotes (and the need to escape the character):

    SELECT * FROM pubs WHERE name LIKE '%John\'s%'
    

提交回复
热议问题