Click here to Skip to main content
15,937,602 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

Please convert this sql stored procedure to Mysql stored procedure.
SQL
CREATE PROC [dbo].[LoadData]
(
   @mode int=NULL,
   @id int=null
)
AS 
BEGIN

   IF(@mode=1)
      BEGIN
         IF(@id>0)
            BEGIN
               SELECT * FROM tbl_user Where pk_userid=@id and bActive=1
            END 
         ELSE
            BEGIN
               SELECT usr1.pk_userid, 
                      usr1.username, 
                      case usr1.roleid 
                         when 1 then 'Admin'
                         when 2 then 'User' 
                         when 3 then 'Sub User' 
                         WHEN 4 then 'Partner' 
                         else 'Super Admin' 
                      END as UserRole,
                      ISNULL(usr2.username,'') As Head 
               FROM tbl_user usr1 
               LEFT JOIN tbl_user usr2 ON usr1.headuserid=usr2.pk_userid
               WHERE usr1.bActive=1 AND usr1.roleid IN (1)
               --WHERE usr1.bActive=1 AND usr1.roleid NOT IN (5)
            END
         END
	
END

Thanks in advance
Rajkumar
Posted
Updated 5-Jun-12 4:46am
v3
Comments
Tim Corey 5-Jun-12 10:31am    
We aren't here to do your work for you. This forum is for people who have tried to get code working and are having problems. Please show us what you have tried and we will try to help you along.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900