Use result obtained in one select query in other statement in MySQL Stored Procedure
<p>I am writing a stored procedure where I am fetching data from one table and based on that data I want to use that data in other manipulations. E.g.</p>

<pre><code>select id,name,email,mobile,user_type from users
</code></pre>

<p>And based on the user_type I want to do further processing using id field . for E.g.,</p>

<pre><code>if(user_type=1) 
   begin
        select * from some_table where Userid = id
   End
Else if (user_type=2)
  begin
      select * from some_other_table where Userid = id
  End
</code></pre>

<p>Can anyone provide me with basic syntax to do that</p>