当前位置:网站首页>MySQL converts comma separated attribute field data from column to row
MySQL converts comma separated attribute field data from column to row
2022-07-03 16:29:00 【Xiao Chen - Programmer】
Mysql Convert comma separated attribute fields to row data
Mysql Convert comma separated attribute fields to row data .
- scene :
At development time , We will design the database table according to the requirements . Sometimes when designing data tables, we can't conform to the three paradigms , Complexity of cause scenario , If we follow the three paradigms all the time , It will increase our development . Sometimes we use commas to store some in an attribute value id It's worth waiting for . When querying, you need to convert attributes into rows .
- data :
- solve :
select a.*,SUBSTRING_INDEX(SUBSTRING_INDEX(a.content,',',b.id),',',-1) content
from temp a
join temp b
where b.id <= LENGTH(a.content)-LENGTH(REPLACE(a.content,',',''))+1
- result :
- Function analysis
SUBSTRING_INDEX : Get separator after separation , Get the string according to the last parameter index , Negative numbers are reciprocal
LENGTH : character string length
REPLACE : Replace string
summary :
join The table needs to find a table whose attribute is 1 Start incremental . They usually use mysql.help_topic This table , But the data in this table id It is limited. , Even in some cases, you don't have permission to access the table .
边栏推荐
- 利用MySQL中的乐观锁和悲观锁实现分布式锁
- 特征多项式与常系数齐次线性递推
- Characteristic polynomial and constant coefficient homogeneous linear recurrence
- EditText request focus - EditText request focus
- Rk3399 platform development series explanation (WiFi) 5.54. What is WiFi wireless LAN
- 用通达信炒股开户安全吗?
- 斑马识别成狗,AI犯错的原因被斯坦福找到了
- Pychart error updating package list: connect timed out
- Central South University | through exploration and understanding: find interpretable features with deep reinforcement learning
- Register in PHP_ Globals parameter settings
猜你喜欢
8个酷炫可视化图表,快速写出老板爱看的可视化分析报告
Record a jar package conflict resolution process
[list to map] collectors Tomap syntax sharing (case practice)
Record windows10 installation tensorflow-gpu2.4.0
关于视觉SLAM的最先进技术的调查-A survey of state-of-the-art on visual SLAM
Mysql 将逗号隔开的属性字段数据由列转行
Explore Cassandra's decentralized distributed architecture
线程池执行定时任务
One article takes you to understand machine learning
From the 18th line to the first line, the new story of the network security industry
随机推荐
Effect of ARP package on FTP dump under vxworks-6.6 system
为抵制 7-Zip,列出 “三宗罪” ?网友:“第3个才是重点吧?”
Page dynamics [2]keyframes
Is it safe to open an account with flush?
Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
Nifi from introduction to practice (nanny level tutorial) - flow
Is it safe to open a stock account by mobile registration? Does it need money to open an account
在ntpdate同步时间的时候出现“the NTP socket is in use, exiting”
nifi从入门到实战(保姆级教程)——flow
Record a jar package conflict resolution process
线程池执行定时任务
Golang anonymous function use
Unity project optimization case 1
Advanced Mathematics (Seventh Edition) Tongji University exercises 2-1 personal solutions
Characteristic polynomial and constant coefficient homogeneous linear recurrence
LeetCode1491. Average value of wages after removing the minimum wage and the maximum wage
Eleven requirements for test management post
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
Aike AI frontier promotion (7.3)
SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]