您的位置:首页 > 其它

一行拆分为多行 instr

2014-07-03 19:33 253 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: