sql 按https://deliciousbrains.com/wp-migrate-db-pro/doc/extracting-subsite-multisite-create-new-singl

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 按https://deliciousbrains.com/wp-migrate-db-pro/doc/extracting-subsite-multisite-create-new-singl相关的知识,希望对你有一定的参考价值。

-- delete any usermeta specific to the other subsites
delete from wp_usermeta where meta_key regexp '^wp_([0-9]+)_';

-- duplicate the wp_usermeta structure in a working data table,
-- but add a unique index for filtering out duplicates
create table _fix_usermeta like wp_usermeta;
alter table _fix_usermeta add unique(user_id, meta_key);

-- copy the site-specific usermeta, keeping only the last of each duplicate
insert into _fix_usermeta
    select * from wp_usermeta
    where meta_key like 'wp\_%'
    order by user_id, meta_key, umeta_id
    on duplicate key update umeta_id=values(umeta_id), meta_value=values(meta_value);

-- remove the first of each duplicate
delete from wp_usermeta
where meta_key like 'wp\_%'
and not exists (select * from _fix_usermeta where umeta_id = wp_usermeta.umeta_id);

-- remove that working data table
drop table _fix_usermeta;

以上是关于sql 按https://deliciousbrains.com/wp-migrate-db-pro/doc/extracting-subsite-multisite-create-new-singl的主要内容,如果未能解决你的问题,请参考以下文章

SQL:按条件从不同表中按计数排序

想问下,sql 按 in 后的顺序排序问题。

按名称查询报表的 SQL 查询,其中许多列按状态计数

sql查询并新增一列,按条件排序后给这一列赋值,并满足条件按序列赋值

sql 按SQL选择和计数组

SQL:如何按特定范围的 ID 编号,然后按时间排序?