2

Is that possible to set two parameters value in single query in Stored Procedure Mysql? I want , two different parameters as output , i don't want to con-cat it.

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;

Any help ?

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 Answer 1

11

Just list them out with commas after the INTO:

SELECT a, b, c
INTO v_a, v_b, v_C
FROM ...
Sign up to request clarification or add additional context in comments.

5 Comments

Hi @siride. How can get these value in next select query like (SELECt id, name, v_a as value1, v_b as value2 FROM table WHERE id =1)
@Kailas: I don't understand the question. Your example SELECT is exactly how you'd get them out.
why is this not working inside a concat query in stored procedure?
@Fakipo Did you declare the variables first? I'd ask in a new question first.
No, it works. we just have to use user defined variables..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.