当前位置:网站首页>ORACLE列转行--某字段按指定分隔符转多行
ORACLE列转行--某字段按指定分隔符转多行
2022-07-06 07:11:00 【游戏编程】
在数据存储数据库中,常常存在信息以特殊符号隔开形式存储在一个字段里
将代码拷贝使用时,需要更改表名、字段名、分隔字符等(注:使用的时候还需将将N替换为分隔符的长度,如分割符“,”,长度位1,则将N替换位1,一共4处)。
SELECT id,substr(a.city, instr(a.city, '、', 1, levels.lvl) + N, instr(a.city, '、', 1, levels.lvl + 1) -(instr(a.city, '、', 1, levels.lvl) + 1)-(N-1)) as city,usernameFROM(SELECT id,'、' || city || '、' AS city,username,(length(city || '、') - nvl(length(REPLACE(city, '、')), 0))/N AS cntFROM userinfomation) a,(SELECT rownum AS lvlFROM (SELECT (MAX(length(city || '、') - nvl(length(REPLACE(city, '、')), 0)))/N max_len FROM userinfomation)CONNECT BY LEVEL <= max_len) levelsWHERE levels.lvl <= a.cntORDER BY id,levels.lvl;

作者:LW_dcwange
游戏编程,一个游戏开发收藏夹~
如果图片长时间未显示,请使用Chrome内核浏览器。
边栏推荐
- 作者已死?AI正用藝術征服人類
- The psychological process from autojs to ice fox intelligent assistance
- 指尖上的 NFT|在 G2 上评价 Ambire,有机会获得限量版收藏品
- leetcode704. Binary search (find an element, simple, different writing)
- Briefly describe the differences between indexes, primary keys, unique indexes, and joint indexes in mysql, and how they affect the performance of the database (in terms of reading and writing)
- 【Hot100】739. Daily temperature
- [hot100] 739. Température quotidienne
- What is the biggest problem that fresh e-commerce is difficult to do now
- After sharing the clone remote project, NPM install reports an error - CB () never called! This is an error with npm itself.
- Uncaught TypeError: Cannot red propertites of undefined(reading ‘beforeEach‘)解决方案
猜你喜欢
Leetcode35. search the insertion position (simple, find the insertion position, different writing methods)
Thought map of data warehouse construction
微信脑力比拼答题小程序_支持流量主带最新题库文件
开源的网易云音乐API项目都是怎么实现的?
Raspberry pie 3B update VIM
leetcode1020. 飞地的数量(中等)
Cif10 actual combat (resnet18)
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
SEO学习的最好方式:搜索引擎
[advanced software testing step 1] basic knowledge of automated testing
随机推荐
leetcode704. Binary search (find an element, simple, different writing)
Yield method of tread
MVVM of WPF
【JDBC】快速入门教程
leetcode59. 螺旋矩阵 II(中等)
Huawei equipment configuration ospf-bgp linkage
多线程和并发编程(二)
Structure summary of SystemVerilog integrable model
Multithreading and concurrent programming (2)
BIO模型实现多人聊天
接口自动化测试框架:Pytest+Allure+Excel
(4) Web security | penetration testing | network security web site source code and related analysis
Short video, more and more boring?
Zhongqing reading news
《从0到1:CTFer成长之路》书籍配套题目(周更)
supervisor 使用文档
Upgraded wechat tool applet source code for mobile phone detection - supports a variety of main traffic modes
Briefly describe the differences between indexes, primary keys, unique indexes, and joint indexes in mysql, and how they affect the performance of the database (in terms of reading and writing)
数据仓库建设思维导图
从autojs到冰狐智能辅助的心里历程