`

instr

阅读更多
--avoid 0 here 
select * from Cost_Mdl_Ver_Type where instr('1002,1003,',mdl_ver_typ_Id||',')>0




select * from Cost_Mdl_Ver_Type where instr('1002,1003,',mdl_ver_typ_Id)>0

-- 0  , 002  , 003 ,100 都会检索出来

 

 

Idea from 

         select level l from dual connect by level <=5;

 

 

And this is the SQL : 

 

SELECT mdl_ver_typ_desc FROM cost_mdl_ver_type where mdl_ver_typ_Id in ( 

 (

 select

   trim( substr (txt,

         instr (txt, ',', 1, level  ) + 1,

         instr (txt, ',', 1, level+1)

            - instr (txt, ',', 1, level) -1 ) )

     as token

    from (select ',1000, 1001,' txt

            from dual)

  connect by level <=

     length('1000, 1001')-length(replace('1000, 1001',',',''))+1

  ) 

  )

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics