如何在LIKE子句中转义方括号? [英] How can I escape square brackets in a LIKE clause?
本文介绍了如何在LIKE子句中转义方括号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用一个存储过程使用like过滤项目。该列是varchar(15)。
I am trying to filter items with a stored procedure using like. The column is a varchar(15). The items I am trying to filter have square brackets in the name.
例如: WC [R] S123456
。
如果我做一个 LIKE'WC [R] S123456'
,它不会返回任何东西。
If I do a LIKE 'WC[R]S123456'
it will not return anything.
我发现了一些关于使用 ESCAPE
关键字和 LIKE
的信息,我不明白如何使用它将方括号作为常规字符串。
I found some information on using the ESCAPE
keyword with LIKE
but I do not understand how to use it to treat the square brackets as a regular string.
推荐答案
LIKE 'WC[[]R]S123456'
或
LIKE 'WC\[R]S123456' ESCAPE '\'
应该工作。
这篇关于如何在LIKE子句中转义方括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文