当前位置:网站首页>Oracle column to row -- a field is converted to multiple rows according to the specified separator
Oracle column to row -- a field is converted to multiple rows according to the specified separator
2022-07-06 07:15:00 【Game programming】
In the data storage database , There is often information to Special symbols The separated form is stored in a field
When copying code for use , The table name needs to be changed 、 Field name 、 Separator characters, etc ( notes : When you use it, you need to put N Replace with Separator The length of , Such as separator “,”, Length bit 1, Will N Replace bit 1, altogether 4 It's about ).
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;
author :LW_dcwange
Game programming , A game development favorite ~
If the picture is not displayed for a long time , Please use Chrome Kernel browser .
边栏推荐
猜你喜欢

Misc of BUU (update from time to time)

SSM学习

Detailed explanation | detailed explanation of internal mechanism of industrial robot

变量的命名规则十二条

Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied

Markdown 中设置图片图注

Hydra common commands

The author is dead? AI is conquering mankind with art

mysql如何合并数据

Development of entity developer database application
随机推荐
navicat如何导入MySQL脚本
JDBC学习笔记
Leetcode59. spiral matrix II (medium)
Leetcode 78: subset
漏了监控:Zabbix对Eureka instance状态监控
You deserve this high-value open-source third-party Netease cloud music player
Supporting title of the book from 0 to 1: ctfer's growth road (Zhou Geng)
Win10 64 bit Mitsubishi PLC software appears oleaut32 DLL access denied
数字IC设计笔试题汇总(一)
[JDBC] quick start tutorial
可变参数重载时的内存错误
杰理之普通透传测试---做数传搭配 APP 通信【篇】
Fast target recognition based on pytorch and fast RCNN
杰理之BLE【篇】
Wechat brain competition answer applet_ Support the flow main belt with the latest question bank file
变量的命名规则十二条
Visitor tweets about how you can layout the metauniverse
Go learning --- use reflection to judge whether the value is valid
MVVM of WPF
Crawling exercise: Notice of crawling Henan Agricultural University