我正在搜索一个全局索引的CLOB,这样我就可以使用一个CONTAINS函数。我搜索的短语是'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'
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’的行。
发布于 2019-04-26 06:02:13
我知道,这是CLOB。不管怎样,INSTR会有什么好处吗?
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>https://stackoverflow.com/questions/55857426
复制相似问题