试试这个。
SELECT
REPLACE(
SUBSTRING_INDEX(
'Collectibles
>
Decorative Collectibles
>
Decorative Collectible Brands
>
Department 56
>
Ornaments
[ Changecategory ]', '[', 1),
'\n >\n',',') output;
输出:
mysql> SELECT
-> REPLACE(
-> SUBSTRING_INDEX(
-> 'Collectibles
'> >
'> Decorative Collectibles
'> >
'> Decorative Collectible Brands
'> >
'> Department 56
'> >
'> Ornaments
'> [ Changecategory ]', '[', 1),
-> '\n >\n',',') output;
+--------------------------------------------------------------------------------------------------+
| output |
+--------------------------------------------------------------------------------------------------+
| Collectibles, Decorative Collectibles, Decorative Collectible Brands, Department 56, Ornaments
|
+--------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)