Is it possible to add a comma between each character of a string on mysql.
From my_table
id | name |
---|---|
1 | hello |
To :
id | name |
---|---|
1 | h,e,l,l,o |
Is it possible to add a comma between each character of a string on mysql.
From my_table
id | name |
---|---|
1 | hello |
To :
id | name |
---|---|
1 | h,e,l,l,o |
2
Answers
If you are using MySQL 8.0, you could try REGEXP_REPLACE function.
See demo here
Another MySQL8 REGEXP_REPLACE –
db<>fiddle and regular expressions 101
Since MySQL 8.0.4 the regex implementation has been using International Components for Unicode (ICU) – patterns and behavior are based on Perl’s regular expressions