当前位置:网站首页>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 .
边栏推荐
- Is it safe to open an account with tongdaxin?
- EditText request focus - EditText request focus
- Cocos Creator 2. X automatic packaging (build + compile)
- Pychart error updating package list: connect timed out
- 跟我学企业级flutter项目:简化框架demo参考
- Visual SLAM algorithms: a survey from 2010 to 2016
- Top k questions of interview
- Visual SLAM algorithms: a survey from 2010 to 2016
- 爱可可AI前沿推介(7.3)
- Détails du contrôle de la congestion TCP | 3. Espace de conception
猜你喜欢
One article takes you to understand machine learning
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (4)
线程池执行定时任务
(补)双指针专题
First knowledge of database
Add color to the interface automation test framework and realize the enterprise wechat test report
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
Interviewer: how does the JVM allocate and recycle off heap memory
随机推荐
[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
《天天数学》连载56:二月二十五日
[statement] about searching sogk1997 and finding many web crawler results
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (III)
1287. Elements that appear more than 25% in an ordered array
Remote file contains actual operation
香港理工大学|数据高效的强化学习和网络流量动态的自适应最优周界控制
Threejs Part 2: vertex concept, geometry structure
Visual SLAM algorithms: a survey from 2010 to 2016
跟我学企业级flutter项目:简化框架demo参考
Pychart error updating package list: connect timed out
切入点表达式
(补)双指针专题
PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
PHP二级域名session共享方案
TCP擁塞控制詳解 | 3. 設計空間
[web security] - [SQL injection] - error detection injection
Getting started with Message Oriented Middleware
如何在本机搭建SVN服务器
Explore Netease's large-scale automated testing solutions see here see here