问题描述:
        某张表某个字段的 值为  K09,K10
        UPDATE 时需要根据这个字段这个值去更新比如:
        update A set flag=2 where areno in (select to_char( '''' ||replace(AREANO,',',''',''')||'''') from b where id='123124')
        to_char 的值为'k09','k10'
        如果直接update A set flag=2 where areno in('k09','k10')肯定是没有问题
        感觉 in中的这个字段的值被oracle 当成一个值了,如何处理成想要的结果
        条件只用1条sql语句OracleSQLselect

解决方案 »

  1.   

    AREANO是什么结构?  如果是以逗号分割的 那直接拆开就可以了
      

  2.   

    select * from table where col in (select *****)里面有几行就是几个参数,你用一行拼接出来没用。
    select regexp_substr('1,12,234','[0-9]+',1,n) a from dual , (select level n from dual connect by level <=3)可以把一行转化为多行
      

  3.   

    你把in改成like试一试?
    前提是保证业务数据都能对的上,不会出现k09和10k这样不规则的数据。
      

  4.   

    update A set flag=2 where exists
    (select 1 from b where b.id='123124'
     and ','||b.areano||',' like '%,'||A.areano||',%')
      

  5.   

    update  A set FLAG=2 where AREANO in(
    select regexp_substr(AREANO,'([^,]+)',1,rownum) 
    from (select AREANO from  B where ID='123124')
    connect by 
    rownum<(length(regexp_replace(AREANO,'[^,]',''))+2)    
    )