How to use apostrophe in LIKE operator on a WHERE clause? Example - WHERE WORD like '%That's why%'

。_饼干妹妹 提交于 2020-11-29 16:22:59

问题


In SQL Server how do I use an apostrophe in the LIKE operator on a WHERE clause?

Example: WHERE WORD like '%That's why%'

I need to fetch the data that matches to word "That's why" in the WORD column.

Dummy data on WORD Column:

  1. So that's why we turned back
  2. and that's why it didn't work

When I use '%That\'s why%', I get

Incorrect syntax near 's'

When I use '%That''s why%', I get the following error

Incorrect syntax near 's why%'


回答1:


WHERE WORD like '%That''s why%'

Example (SQL Server):



来源:https://stackoverflow.com/questions/64999187/how-to-use-apostrophe-in-like-operator-on-a-where-clause-example-where-word-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!