当前位置:网站首页>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内核浏览器。
边栏推荐
- Supporting title of the book from 0 to 1: ctfer's growth road (Zhou Geng)
- On the world of NDK (2)
- 简单描述 MySQL 中,索引,主键,唯一索引,联合索引 的区别,对数据库的性能有什么影响(从读写两方面)
- The first Baidu push plug-in of dream weaving fully automatic collection Optimization SEO collection module
- 数据仓库建设思维导图
- Proteus -- Serial Communication parity flag mode
- Upgraded wechat tool applet source code for mobile phone detection - supports a variety of main traffic modes
- Crawling exercise: Notice of crawling Henan Agricultural University
- Depth residual network
- Project GFS data download
猜你喜欢
Babbitt | metauniverse daily must read: the group image of Chinese Internet enterprises pouring into metauniverse: "there are only various survival desires, and there is no ambition for forward-lookin
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
攻防世界 MISC中reverseMe简述
[advanced software testing step 1] basic knowledge of automated testing
Fast target recognition based on pytorch and fast RCNN
Solution to the problem of breakthrough in OWASP juice shop shooting range
作者已死?AI正用艺术征服人类
Leetcode 78: subset
ROS learning_ Basics
Raspberry pie 3B update VIM
随机推荐
Uncaught TypeError: Cannot red propertites of undefined(reading ‘beforeEach‘)解决方案
前缀和数组系列
The best way to learn SEO: search engine
Blue Bridge Cup zero Foundation National Championship - day 20
Leetcode35. search the insertion position (simple, find the insertion position, different writing methods)
Refer to how customer push e-commerce does content operation
“无聊猿” BAYC 的内忧与外患
数据仓库建设思维导图
Entity Developer数据库应用程序的开发
leetcode704. 二分查找(查找某个元素,简单,不同写法)
GET 和 POST 请求类型的区别
Supporting title of the book from 0 to 1: ctfer's growth road (Zhou Geng)
PCL实现选框裁剪点云
1091: two or three things in childhood (multi instance test)
[some special grammars about C]
Thought map of data warehouse construction
【每日一题】729. 我的日程安排表 I
呆错图床系统源码图片CDN加速与破解防盗链功能
What does UDP attack mean? UDP attack prevention measures
Cookie技术&Session技术&ServletContext对象