首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何允许在'B&B‘上使用CONTAINS进行搜索,而不会因为&和get only 'B&B’而得到'Enter Substitution‘的提示

如何允许在'B&B‘上使用CONTAINS进行搜索,而不会因为&和get only 'B&B’而得到'Enter Substitution‘的提示
EN

Stack Overflow用户
提问于 2019-04-26 04:49:53
回答 1查看 14关注 0票数 0

我正在搜索一个全局索引的CLOB,这样我就可以使用一个CONTAINS函数。我搜索的短语是'B&B‘。我尝试了多种方法来转义&,因此它不会被视为用户输入的提示。我不能做这件事。

代码语言:javascript
复制
select * from table where contains(txt, '({B&B})')>0;--this gives me substitution variable prompt

select * from table where contains(txt, '({B}{&}{B})')>0;--this finds 'B B'

select * from table where contains(txt, '(B{&}B)')>0;--this finds 'B B'

select * from table where contains(txt, '({B&B})')>0;--this gives me substitution variable prompt

select * from table where contains(txt, '({B&}B)')>0;--this finds 'B B', 'B.B', 'B&B'

select * from table where contains(txt,'NEAR (({B&},(B)),1)') > 0;--this finds 'B B', 'B.B', 'B&B'

select * from table where txt like '%B&B%';--this gives me substitution variable prompt

我不能取消使用替代变量提示符的功能,所以这必须在代码中完成。

我需要忽略所有出现的'B B','B.B‘,让它只返回这个字段中有'B&B’的行。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-26 06:02:13

我知道,这是CLOB。不管怎样,INSTR会有什么好处吗?

代码语言:javascript
复制
SQL> create table test (txt clob);

Table created.

SQL> set define off
SQL> insert into test
  2    select 'This is an example which does not contain BB, B B, B.B' from dual union all
  3    select 'Query should return B&B because it is here' from dual;

2 rows created.

SQL> select txt
  2  from test
  3  where instr(txt, 'B&B') > 0;

TXT
--------------------------------------------------------------------------------
Query should return B&B because it is here

SQL>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55857426

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档