从mysql字段中剪切特定字符串并使用字符串更新相同字段

时间:2014-02-20 23:57:48

标签: mysql regex

我正在寻找一个更新mysql表中现有字段的选项,其中标题为

+---------------------------------------------------------------------+---------+
| title                                                               | albumid |
+---------------------------------------------------------------------+---------|
| a:1:{s:5:"en_US";s:11:"Donau river";}                               |     171 |
| a:1:{s:5:"en_US";s:26:"The Sunset of River Danube";}                |     171 |
| a:1:{s:5:"en_US";s:26:"quiet evening at the river";}                |     171 |
| a:1:{s:5:"en_US";s:20:"river beach interior";}                      |     171 |
| a:1:{s:5:"en_US";s:41:"A quiet evening on the beach at the river";} |     171 |

想要修剪标题字段,例如

a:1:{s:5:“en_US”; s:11:“Donau river”;}

多瑙河

使用这个新值同时更新mysql字段?

1 个答案:

答案 0 :(得分:1)

试试这个

UPDATE yourTable 
SET title = SUBSTRING_INDEX(SUBSTRING_INDEX(title,'";}',1),':"',-1);