Sql 拆分字符串并在Like命令中使用

Sql 拆分字符串并在Like命令中使用,sql,oracle,Sql,Oracle,我有一个类似“from+google+world”的字符串 我需要在任何地方搜索整个三个关键字的文本 对于我们使用的单个查询 select * from tabl name where desc like '%from%' and desc like '%google%' and desc like '%world%' 如何拆分字符串并将其用于上述查询。 @p1+@p2+@p3 Radu Gheorghiu:这个命令有50%的帮助,它只是用De Limiter拆分字符串,我必须得到一个列

我有一个类似“from+google+world”的字符串

我需要在任何地方搜索整个三个关键字的文本 对于我们使用的单个查询

select * from tabl name 
where desc like '%from%' 
and desc like '%google%' 
and desc like '%world%'
如何拆分字符串并将其用于上述查询。 @p1+@p2+@p3


Radu Gheorghiu:这个命令有50%的帮助,它只是用De Limiter拆分字符串,我必须得到一个列,它有3个拆分的单词,例如我们必须得到Desc,比如'all@p3 things@p1 going@p2 fine'和Desc,而不是'all@p3 things@p1 going fine'

你是指这个输出吗

from
google
world

WITH t AS (SELECT 'from+google+world' word FROM dual)
SELECT regexp_substr(word, '[[:alpha:]]+', 1, LEVEL) FROM T
CONNECT BY regexp_substr(word, '[[:alpha:]]+', 1, level) is not null;
from
google
world

WITH t AS (SELECT 'from+google+world' word FROM dual)
SELECT regexp_substr(word, '[[:alpha:]]+', 1, LEVEL) FROM T
CONNECT BY regexp_substr(word, '[[:alpha:]]+', 1, level) is not null;

你是说这个输出吗

from
google
world

WITH t AS (SELECT 'from+google+world' word FROM dual)
SELECT regexp_substr(word, '[[:alpha:]]+', 1, LEVEL) FROM T
CONNECT BY regexp_substr(word, '[[:alpha:]]+', 1, level) is not null;
from
google
world

WITH t AS (SELECT 'from+google+world' word FROM dual)
SELECT regexp_substr(word, '[[:alpha:]]+', 1, LEVEL) FROM T
CONNECT BY regexp_substr(word, '[[:alpha:]]+', 1, level) is not null;
或者如果您在包含这些单词的表中搜索, 您可以从oracle中选择包含已编制索引的函数:

链接此处:


CTXCAT在这里搜索:

这是您需要的代码,并且

SELECT * FROM tablename WHERE desc IN (
    SELECT regexp_substr('from+google+world','[^+]+', 1, level) FROM dual
    CONNECT BY regexp_substr('from+google+world', '[^+]+', 1, level)
    is not null
);