从mysql数据库中的元值中删除单词

时间:2015-05-19 01:28:57

标签: mysql wordpress

我有一个wordpress数据库,在我的用户元数据的功能下,他们每个人都分配了一些不同的功能,我想删除

bbp_participant
从meta_value表中

而不删除其余的。 meta_value表中的整行是

a:2:{s:11:"contributor";b:1;s:15:"bbp_participant";b:1;}

Database image

您可以在此处查看完整的较大图片Link to Image

编辑:

现在我在元数值中做了一点澄清

a:2:{s:11:"contributor";b:1;s:15:"bbp_participant";b:1;}

我想运行查询以删除s:15:"bbp_participant";b:1;

所以唯一剩下的就是s:11:"contributor";b:1;

1 个答案:

答案 0 :(得分:1)

基本格式是这样的查询:

update wp_usermeta t
    set meta_value = replace(meta_value, 'bbp_participant', '')
    where meta_value like '%bbp_participant%';

编辑:

类型和长度可能总是相同,所以如果你想删除它们:

update wp_usermeta t
    set meta_value = replace(meta_value, 's:15:"bbp_participant";', '')
    where meta_value like '%s:15:"bbp_participant";%';