修改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);