码迷,mamicode.com
首页 > 数据库 > 详细

Oracle字段根据逗号分割查询数据

时间:2018-08-06 13:47:00      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:ref   not   www   post   img   guid   nec   逗号   value   

需求是表里的某个字段存储的值是以逗号分隔开来的,要求根据分隔的每一个值都能查出来数据,但是不能使用like查询。

数据是这样的:

技术分享图片

查询的sql如下:

select * from (
    select guid, regexp_substr(st_responsible, ‘[^,]+‘, 1, level) responsible 
        from tt_cancle_responsible 
        connect by level <= regexp_count(st_responsible, ‘,‘) + 1
        and guid = prior guid
        and prior dbms_random.value is not null )
where responsible =‘wyy‘;

 查询结果如下:

技术分享图片

Oracle字段根据逗号分割查询数据

标签:ref   not   www   post   img   guid   nec   逗号   value   

原文地址:https://www.cnblogs.com/wangyayun/p/9429672.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!