当前位置:网站首页>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 .
边栏推荐
- [web security] - [SQL injection] - error detection injection
- Is it safe to open an account with tongdaxin?
- Is it safe to open a stock account by mobile registration? Does it need money to open an account
- nifi从入门到实战(保姆级教程)——flow
- Pyinstaller is not an internal or external command, nor is it a runnable program or batch file
- 远程办公之大家一同实现合作编辑资料和开发文档 | 社区征文
- Develop team OKR in the way of "crowdfunding"
- QT serial port UI design and solution to display Chinese garbled code
- 深入理解 SQL 中的 Grouping Sets 语句
- 2022爱分析· 国央企数字化厂商全景报告
猜你喜欢

Explore Netease's large-scale automated testing solutions see here see here

Deep understanding of grouping sets statements in SQL

(补)双指针专题

The mixlab editing team is recruiting teammates~~

线程池执行定时任务

Initial test of scikit learn Library

什么是质押池,如何进行质押呢?

初试scikit-learn库

Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package

NSQ source code installation and operation process
随机推荐
Remote file contains actual operation
NSQ source code installation and operation process
Détails du contrôle de la congestion TCP | 3. Espace de conception
Mysql 单表字段重复数据取最新一条sql语句
利用MySQL中的乐观锁和悲观锁实现分布式锁
Interviewer: how does the JVM allocate and recycle off heap memory
Data driving of appium framework for mobile terminal automated testing
One article takes you to understand machine learning
A survey of state of the art on visual slam
Golang decorator mode and its use in NSQ
[combinatorics] combinatorial identities (sum of variable terms 3 combinatorial identities | sum of variable terms 4 combinatorial identities | binomial theorem + derivation to prove combinatorial ide
架构实战营 - 第 6 期 毕业总结
Explore Cassandra's decentralized distributed architecture
Central South University | through exploration and understanding: find interpretable features with deep reinforcement learning
Qt插件之自定义插件构建和使用
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
Zebras are recognized as dogs, and Stanford found the reason why AI made mistakes
Page dynamics [2]keyframes
Uploads labs range (with source code analysis) (under update)
Myopia: take off or match glasses? These problems must be understood clearly first