当前位置:网站首页>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内核浏览器。
边栏推荐
- 网络安全基础介绍
- Uncaught TypeError: Cannot red propertites of undefined(reading ‘beforeEach‘)解决方案
- 19.段页结合的实际内存管理
- [server data recovery] case of offline data recovery of two hard disks of IBM server RAID5
- On the world of NDK (2)
- SSM learning
- Compile, connect -- notes-2
- 开源的网易云音乐API项目都是怎么实现的?
- Leetcode35. search the insertion position (simple, find the insertion position, different writing methods)
- Markdown 中设置图片图注
猜你喜欢
首发织梦百度推送插件全自动收录优化seo收录模块
leetcode704. 二分查找(查找某个元素,简单,不同写法)
leetcode1020. Number of enclaves (medium)
idea控制台彩色日志
Internal and external troubles of "boring ape" bayc
漏了监控:Zabbix对Eureka instance状态监控
[advanced software testing step 1] basic knowledge of automated testing
C language_ Double create, pre insert, post insert, traverse, delete
Configure raspberry pie access network
开源的网易云音乐API项目都是怎么实现的?
随机推荐
JDBC learning notes
Uni app third party package configuration network request
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
SSM学习
Bio model realizes multi person chat
前缀和数组系列
GET 和 POST 请求类型的区别
编译,连接 -- 笔记 -2
Arduino tutorial - Simon games
作者已死?AI正用艺术征服人类
leetcode35. 搜索插入位置(简单,找插入位置,不同写法)
RichView TRVStyle 模板样式的设置与使用
OpenGL ES 学习初识(1)
L'auteur est mort? Ai utilise l'art pour conquérir l'humanité
Uni app practical project
Hydra common commands
idea控制台彩色日志
Supporting title of the book from 0 to 1: ctfer's growth road (Zhou Geng)
Top test sharing: if you want to change careers, you must consider these issues clearly!
1189. Maximum number of "balloons"