搜索
您的当前位置:首页正文

MySQL逗号分割字段的行列转换技巧_MySQL

2020-11-09 来源:易榕旅游

表数据:

ID Value
1tiny,small,big
2small,medium
3tiny,big

期望得到结果:

IDValue
1tiny
1small
1big
2small
2medium
3tiny
3big

正文:

#需要处理的表create table tbl_name (ID int ,mSize varchar(100));insert into tbl_name values (1,'tiny,small,big');insert into tbl_name values (2,'small,medium');insert into tbl_name values (3,'tiny,big');#用于循环的自增表create table incre_table (AutoIncreID int);insert into incre_table values (1);insert into incre_table values (2);insert into incre_table values (3);
bitsCN.com
Top