当前位置:网站首页>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内核浏览器。
边栏推荐
猜你喜欢

树莓派串口登录与SSH登录方法

idea控制台彩色日志

hydra常用命令

Cookie Technology & session Technology & ServletContext object

Week6 weekly report

因高额网络费用,Arbitrum 奥德赛活动暂停,Nitro 发行迫在眉睫

The best way to learn SEO: search engine

Depth residual network

Wechat official account infinite callback authorization system source code, launched in the whole network

Internal and external troubles of "boring ape" bayc
随机推荐
网络安全基础介绍
idea控制台彩色日志
TS基础篇
指尖上的 NFT|在 G2 上评价 Ambire,有机会获得限量版收藏品
#systemverilog# 可综合模型的结构总结
NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections
ROS学习_基础
LeetCode 78:子集
Structure summary of SystemVerilog integrable model
[JDBC] quick start tutorial
UWA pipeline version 2.2.1 update instructions
supervisor 使用文档
Cif10 actual combat (resnet18)
Multithreading and concurrent programming (2)
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
【服务器数据恢复】IBM服务器raid5两块硬盘离线数据恢复案例
微信脑力比拼答题小程序_支持流量主带最新题库文件
MPLS experiment
Raspberry pie serial port login and SSH login methods
What is the biggest problem that fresh e-commerce is difficult to do now