mysql原生sql处理,按逗号拆分列为多行
2024-10-19 11:57:36
举例:
id | value |
1 | 1,2,3,4 |
2 | 2,3,4,5,6 |
拆分成:
id | value |
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 5 |
6 | 6 |
select distinct substring_index(substring_index(a.value,',',b.help_topic_id+1),',',-1)
from table a join mysql.help_topic b on b.help_topic_id < (length(a.value) - length(replace(a.value,',',''))+1)
distinct:去重复操作
a.value:表别名.需要拆分的字段名
table a:表名 别名
help_topic:自增长表
最新文章
- [ios]关于用FMDB 操作数据库 删除 tableView 后刷新
- Java之流程控制语句
- Spring中Bean的生命周期方法
- xml对象的序列化和反序列化
- JS&;CSS文件请求合并及压缩处理研究(四)
- Codeforces Round #143 (Div. 2) E. Cactus 无向图缩环+LCA
- framebuff 显示子系统
- halcon的算子列表
- OpenMeetings(3)----启动顺序解析
- MYSQL while 、repeat
- Linux网络管理之net-tools VS iproute2
- 空指针错误 java.lang.NullPointerException
- 求m区间内的最小值
- 管理Mac的Python环境
- HashMap和Hashtable的异同点
- java Api 读取HDFS文件内容
- Vue-详解设置路由导航的两种方法: <;router-link :to=";...";>; 和router.push(...)
- bzoj 3295 动态逆序对 (三维偏序,CDQ+树状数组)
- DHCP协议和PXE
- hdu 3836 Equivalent Sets trajan缩点
热门文章
- ML- 线性回归推导
- linux/unix发行清单
- Django 之 cookie &; session
- 从SQLAlchemy的“缓存”问题说起
- 自定义微信小程序swiper轮播图面板指示点的样式
- git分布式版本控制系统的概述和安装
- Maven 报错:Compilation of Maven projects is supported only if external build is started from an IDE.
- 五个wordpress调用随机文章的方法
- cf1158A-The Party and Sweets - (贪心+思维)
- LeetCode 953. Verifying an Alien Dictionary