在MySQL声明中选择INTO多变量

时间:2013-05-08 16:56:01

标签: mysql variables

是否可以在存储过程Mysql中的单个查询中设置两个参数值? 我想要两个不同的参数作为输出,我不想接受它。

Declare v_first_name varchar(100);
Declare v_last_name Varchar(100);

SET p_email_id = 'some_email_id';

/* 
instead of this i want to laod result in single query   
Set v_first_name=(Select first_name From user_master Where email_id=p_email_id);
Set v_last_name=(Select last_name From user_master Where email_id=p_email_id);

*/

if flag1=1 then 
Select 1 As 'Result',v_first_name As 'first_name',v_last_name As 'last_name';  
else    
Select 0 As 'Result',v_first_name As 'first_name',v_last_name  As 'last_name';
End if;

任何帮助?

select first_name INTO @v_first_name , last_name INTO @v_last_name From user_master Where email_id=p_email_id; ==== **Not Working**

1 个答案:

答案 0 :(得分:10)

只需在INTO

之后用逗号列出它们
SELECT a, b, c
INTO v_a, v_b, v_C
FROM ...