view plaincopy to clipboardprint?
CREATE PROCEDURE `test`
(IN _login VARCHAR(32),
IN _psw VARCHAR(32),
OUT _ret INTEGER(10),
OUT _id INTEGER(10),
OUT _name VARCHAR(32),
OUT _email VARCHAR(32),
OUT _phone VARCHAR(20),
OUT _active INTEGER(11)) //同时返回多个结果集合
BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND set _ret =-1;
set _ret = 0 ;
select id,name,email,phone,active
into _id,_name,_email,_phone,_active
from test
where tx_account.`loginname`=_login and tx_account.`password`=MD5(_psw) and active=1;
---------返回结果集-----
if _ret = 0 then
select a.id as id ,a.name as name,a.priority as priority
from test b left join test1 a on b.role=a.id
where b.account=_id;
end if;
END;