求解决一条oracle 语句IN的问题

Rockstone 2013-07-09 11:04:23
问题描述:
某张表某个字段的 值为 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语句
...全文
148 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
roadByroad 2013-07-09
  • 打赏
  • 举报
回复
你把in改成like试一试? 前提是保证业务数据都能对的上,不会出现k09和10k这样不规则的数据。
forgetsam 2013-07-09
  • 打赏
  • 举报
回复
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)可以把一行转化为多行
  • 打赏
  • 举报
回复
AREANO是什么结构? 如果是以逗号分割的 那直接拆开就可以了
Rockstone 2013-07-09
  • 打赏
  • 举报
回复
难道木有人在吗
Rockstone 2013-07-09
  • 打赏
  • 举报
回复
求大牛解答,在线等
Rockstone 2013-07-09
  • 打赏
  • 举报
回复
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) )
shy315 2013-07-09
  • 打赏
  • 举报
回复
update A set flag=2 where exists
(select 1 from b where b.id='123124'
 and ','||b.areano||',' like '%,'||A.areano||',%')

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧