运行mysql过程select操作会生成许多结果集
我使用mysql程序来选择结果运行mysql过程select操作会生成许多结果集,mysql,resultset,procedure,Mysql,Resultset,Procedure,我使用mysql程序来选择结果 delimiter // DROP procedure IF EXISTS prd_action; create procedure prd_action() BEGIN DECLARE v_userid int; DECLARE done INT DEFAULT 0; DECLARE cur CURSOR FOR SELECT distinct user_id from friends where user_id > 30; DECLARE CONTINU
delimiter //
DROP procedure IF EXISTS prd_action;
create procedure prd_action()
BEGIN
DECLARE v_userid int;
DECLARE done INT DEFAULT 0;
DECLARE cur CURSOR FOR SELECT distinct user_id from friends where user_id > 30;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cur;
REPEAT
FETCH cur into v_userid;
if not done then
select * from friends where user_id = v_usetid
end if;
UNTIL done END REPEAT;
CLOSE cur;
END//
delimiter
resultset1、resultset2、…、resultset10它们是resultsets,但我希望它们组合成一个resultsets 试试这个:
delimiter //
DROP procedure IF EXISTS prd_action;
create procedure prd_action()
BEGIN
select * from friends f
where user_id > 30;
END//
delimiter ;
----编辑---
如果必须使用v_usetid参数而不是30,请尝试以下代码:
create procedure prd_action(v_userid int)
BEGIN
select * from friends f
where user_id > v_userid;
END/
演示-->@user3044480我添加了一个如何使用参数而不是常量的示例