选择状态或类似或REGEXP

时间:2017-06-05 16:17:32

标签: sql oracle

我有一张表 new_table

ID            DESCRIPTION
1             abdad jadjnd kandkadn 01/19-P-154-37
2             jscbsjc jscnscj 01/19-H-443-38 sbjcj sjcnjscn
3             scjbcs sc, scnsc 01/19-P-16-39 sjcbnjcs
4             scbcsjc 01/19-K-139-40 hcbchsb

AND LISTS

01/19-P-154-37
01/19-H-443-38
01/19-K-139-40

我想

select * from new_table where descriptin in (
01/19-P-154-37
01/19-H-443-38
01/19-P-16-39
01/19-K-139-40
)

或者我现在不请求帮助

1 个答案:

答案 0 :(得分:0)

我想你想要这样的东西(和喜欢的运算符一起加入):

with new_table (ID,            DESCRIPTION) as (
    select 1 ,'abdad jadjnd kandkadn 01/19-P-154-37' from dual union all
    select 2 ,'jscbsjc jscnscj 01/19-H-443-38 sbjcj sjcnjscn' from dual union all
    select 3 ,'scjbcs sc, scnsc 01/19-P-16-39 sjcbnjcs' from dual union all
    select 4 ,'scbcsjc 01/19-K-139-40 hcbchsb' from dual
) ,
LISTS(val) as(
    select '01/19-P-154-37' from dual union all
    select '01/19-H-443-38' from dual union all
    select '01/19-K-139-40' from dual  
)

-- Below is actual query:    

select new_table.* from new_table 
inner join LISTS
on new_table.DESCRIPTION   like '%'||LISTS.val||'%'