当前位置:网站首页>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 .
边栏推荐
- 消息队列消息丢失和消息重复发送的处理策略
- AcWing 第58 场周赛
- Détails du contrôle de la congestion TCP | 3. Espace de conception
- [proteus simulation] 8 × 8LED dot matrix screen imitates elevator digital scrolling display
- 手机注册股票开户安全吗 开户需要钱吗
- [redis foundation] understand redis master-slave architecture, sentinel mode and cluster together (Demo detailed explanation)
- SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
- Caching mechanism of Hibernate / session level caching mechanism
- Initial test of scikit learn Library
- Pointcut expression
猜你喜欢

Myopia: take off or match glasses? These problems must be understood clearly first

Interviewer: how does the JVM allocate and recycle off heap memory

Basis of target detection (IOU)

From "zero sum game" to "positive sum game", PAAS triggered the third wave of cloud computing

爱可可AI前沿推介(7.3)

Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (4)

初试scikit-learn库

QT serial port UI design and solution to display Chinese garbled code

8 cool visual charts to quickly write the visual analysis report that the boss likes to see

深入理解 SQL 中的 Grouping Sets 语句
随机推荐
Cocos Creator 2.x 自动打包(构建 + 编译)
[combinatorics] combinatorial identity (sum of combinatorial identity products 1 | sum of products 1 proof | sum of combinatorial identity products 2 | sum of products 2 proof)
TCP congestion control details | 3 design space
Uploads labs range (with source code analysis) (under update)
NSQ源码安装运行过程
Mongodb installation and basic operation
[solved] access denied for user 'root' @ 'localhost' (using password: yes)
关于视觉SLAM的最先进技术的调查-A survey of state-of-the-art on visual SLAM
(Supplement) double pointer topic
[combinatorics] non descending path problem (outline of non descending path problem | basic model of non descending path problem | non descending path problem expansion model 1 non origin starting poi
AcWing 第58 场周赛
TCP拥塞控制详解 | 3. 设计空间
面试官:JVM如何分配和回收堆外内存
From the 18th line to the first line, the new story of the network security industry
Hibernate的缓存机制/会话级缓存机制
The mixlab editing team is recruiting teammates~~
0214-27100 a day with little fluctuation
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (4)
Client does not support authentication protocol requested by server; consider upgrading MySQL client
One article takes you to understand machine learning