mysql使用存储过程分表分页查询

2021/7/7 19:07:37

本文主要是介绍mysql使用存储过程分表分页查询,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

修改mysql默认结束符

delimiter $$

定义存储过程

CREATE PROCEDURE union_select(IN page INTEGER)
BEGIN
    declare start int;
    set start=(page-1)*20;

    SELECT * from table UNION SELECT * from table1 UNION SELECT * from table2 UNION SELECT * from table3 UNION  SELECT * from table4 UNION SELECT * from table5 UNION SELECT * from table6 UNION SELECT * from table7 UNION SELECT * from table8 UNION SELECT * from table9 LIMIT start, 20;
END$$

还原mysql结束符

delimiter ;

调用存储过程

call union_select(1);



这篇关于mysql使用存储过程分表分页查询的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程