一行拆分为多行 instr

来源:互联网 发布:彩票预算软件 编辑:程序博客网 时间:2024/06/06 02:13

tableA : g_supply_info 

column: product_unit: (1,2,3)

将str去掉()

sql:

<pre name="code" class="sql">update bemms.g_supply_info si set si.product_unit=replace(replace(si.product_unit ,'('),')')



一行拆分为多行,使用函数regexp_substr

一行数据  id           product_category

                 10001    1,2,3

拆分为 id            product_category

            10001         1

           10001          2

           10001          3

 sql:

SELECT DISTINCT regexp_substr(category, '[^,]+', 1, level) category,                                id                  FROM (SELECT id, product_category category                          FROM g_contract_info)                CONNECT BY LEVEL <= LENGTH(category) -                           LENGTH(REPLACE(category, ',', '')) + 1 

查询a是否在abc中

sql:

select instr('abc','a') from dual 




0 0
原创粉丝点击