1

I dont want to use any function or any procedure.

I want simple select query to check the existance of the each part of string.

like i have one table dummy which have name column

                         Id     name 
                          1   as;as;as
                          2    asd;rt

and child table

                       child_id       name
                          23           as
                          24           asd
                          25           rt

so any i can do that

i have tried like

select substr(first_name,1,instr(first_name,';')-1) from dummy;
select substr(first_name,instr(first_name,';')+1,instr(first_name,';')-1) 
                                                               from dummy;

Which is giving only first/second part but other part how to get other part

4

2 回答 2

0

如果我做对了 - 如果孩子的 NAME 包含在 DUMMY.Name 中,您需要加入这些表

SQLFiddle 示例

select t1.*, 
       t2.child_id, 
        t2.name as t2name 
from t1
left join t2 on (';'||t1.name||';' like '%;'||t2.name||';%')
于 2013-01-17T14:06:42.370 回答
0

我需要关于这个问题的更多信息。我们不知道您是否必须在一个字段上检测多个可能的字符串。

您可以为三种可能的情况使用三个类似的子句

  1. LIKE column_name ||'%;'
  2. 喜欢'%;'|| 列名
  3. 喜欢';%'|| 列名 ||'%;'

但它可能更适合未来学习构建正则表达式。这是一个对我帮助很大的网页:txt2re.com

于 2013-01-17T14:18:06.147 回答