当前位置:网站首页>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 .
边栏推荐
- Record windows10 installation tensorflow-gpu2.4.0
- EditText request focus - EditText request focus
- Eleven requirements for test management post
- LeetCode1491. Average value of wages after removing the minimum wage and the maximum wage
- 于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
- 线程池执行定时任务
- [list to map] collectors Tomap syntax sharing (case practice)
- Characteristic polynomial and constant coefficient homogeneous linear recurrence
- Using optimistic lock and pessimistic lock in MySQL to realize distributed lock
- 面试之 top k问题
猜你喜欢

NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon

Détails du contrôle de la congestion TCP | 3. Espace de conception

消息队列消息丢失和消息重复发送的处理策略

Zebras are recognized as dogs, and Stanford found the reason why AI made mistakes
![[proteus simulation] 8 × 8LED dot matrix screen imitates elevator digital scrolling display](/img/46/c7f566f8fd46d383b055582d680bb7.png)
[proteus simulation] 8 × 8LED dot matrix screen imitates elevator digital scrolling display

NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线

Unreal_ Datatable implements ID self increment and sets rowname

Netease UI automation test exploration: airtest+poco

Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..

Aike AI frontier promotion (7.3)
随机推荐
Google Earth engine (GEE) - daymet v4: daily surface weather data set (1000m resolution) including data acquisition methods for each day
架构实战营 - 第 6 期 毕业总结
14 topics for performance interviews between superiors and subordinates (4)
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (II)
TCP congestion control details | 3 design space
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
Advanced Mathematics (Seventh Edition) Tongji University exercises 2-1 personal solutions
Leetcode binary search tree
[redis foundation] understand redis persistence mechanism together (rdb+aof graphic explanation)
Cocos Creator 2.x 自动打包(构建 + 编译)
Nine ways to define methods in scala- Nine ways to define a method in Scala?
2022 love analysis · panoramic report of digital manufacturers of state-owned enterprises
Golang anonymous function use
PHP secondary domain name session sharing scheme
中南大学|通过探索理解: 发现具有深度强化学习的可解释特征
From "zero sum game" to "positive sum game", PAAS triggered the third wave of cloud computing
Unity project optimization case 1
Getting started with Message Oriented Middleware
Everyone in remote office works together to realize cooperative editing of materials and development of documents | community essay solicitation
PHP CI (CodeIgniter) log level setting