[英]What solution function Postgresql regexp_split_to_table in Mysql
在PostgreSQL中有一个功能
Select id, regexp_split_to_table(meta_value) from metas;
日期:
1, '45,46,47'
2, '10'
3, ''
4, '12,4558,456'
需要相同的结果
1, '45'
1, '45'
1, '47'
2, '10'
3, ''
4, '12'
4, '4558'
4, '456'
Mysql有什么解决方案?
是链接一栏但导致一栏,需要两栏或更多栏
尝试使用substring_index函数
select id, substring_index(substring_index(meta_value, ',', n), ',', -1
) as meta_value
from metas join metas on char_length(meta_value) -
char_length(replace(meta_value, ',', '')) >= n - 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.