mysql 存储过程 查询 wordpress multi模式下

2019-08-21  本文已影响0人  xiongyi

drop PROCEDURE if exists find_options;

create procedure find_options()

BEGIN

DECLARE done int DEFAULT 0;

declare blogid int;

declare cur cursor for select blog_id from sitebuilt_blog.wp_blogs b;

declare CONTINUE HANDLER for SQLSTATE '02000' set done = 1;

open cur;

REPEAT

    fetch cur into blogid;

    if not done THEN

            set @blogid=blogid;

            if not EXISTS (select table_name from information_schema.tables where table_schema = 'sitebuilt_blog' and table_name = CONCAT('wp_',@blogid,'_options') limit 1)

            THEN

                select @blogid;

            end if;

    end if;

UNTIL done END REPEAT;

close cur;

end;

call find_options();

上一篇 下一篇

猜你喜欢

热点阅读