56,677
社区成员
发帖
与我相关
我的任务
分享
DELIMITER $$
DROP FUNCTION IF EXISTS `Myf`$$
CREATE FUNCTION Myf() RETURNS varchar(50)
begin
return '11';
end$$
DELIMITER ;
CREATE
FUNCTION processRoleName(user_id int(11) )
RETURNS varchar(100) CHARSET utf8
BEGIN
declare returnStr varchar(100);
select returnStr=ifnull(returnStr,',')+name from
role,user_role where id=rid and uid=user_id;
return returnStr;
end;
mysql> show variables like '%func%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | OFF |
+---------------------------------+-------+
1 row in set (0.00 sec)
mysql> set global log_bin_trust_function_creators=1;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%func%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | ON |
+---------------------------------+-------+
1 row in set (0.00 sec)
mysql>
select a.*,group_concat(c.name) as user_role
from `user` a
inner join user_role b on a.id=b.uid
inner join role c on b.rid=c.id