0

I have a table with a column name title however the data has apostrophe in it.
My query input parameter removes all apostrophe from it, how would you compare like or equal to get that row back?

select * from authors..atricles where title = 'buyers'
buyer's = 'buyers' or like '%buyers%'

If a user inputs buyer's on the page it will remove ' and the new input string will be buyers.

4

2 回答 2

2

为了逃避它,你添加另一个单引号:

WHERE title LIKE '%buyer''s%'

既然您提到您的查询输入参数删除了所有撇号,那么您将使用搜索REPLACE

WHERE REPLACE(title, '''', '') = 'buyers'

以这种方式使用函数将使任何可能的索引无用。

于 2013-04-18T17:58:13.360 回答
0

我认为这应该有效:

SELECT * FROM authors WHERE title LIKE'%buyer%'
于 2013-04-18T18:10:28.147 回答