有一个字符串 比如A='a,b,c'
想把它转换成'a','b','c'作为in 的条件
select * from t1 where t1.field in (A)
应该怎么转换?

解决方案 »

  1.   

    使用别名,将该表看成是两张表,
    select first.A from t1 first ,t1 second where first.A=substr(second.a,0,1) or first.A = substr(second.a,2,1) or first.A = substr(second.a,4,1)
      

  2.   

    SQL> select regexp_substr('SMITH,ALLEN,WARD,JONES','[^,]+', 1, level) from dual
      2  connect by regexp_substr('SMITH,ALLEN,WARD,JONES', '[^,]+', 1, level) is not null;
    REGEXP_SUBSTR('SMITH,A
    ----------------------
    SMITH
    ALLEN
    WARD
    JONES
      

  3.   


    感谢crazy_samba的回答 本人对于connect by 不是很熟悉
    那么我是想用表中的一个字段去in 那么该如何写呢?