树形结构通过节点获取节点所有上级(函数)
1 create function get_department_list(in_id int) returns varchar(100) 2 READS SQL DATA 3 begin 4 declare ids varchar(1000); 5 declare tempid int; 6 7 set tempid = in_id; 8 while tempid > 0 do 9 set ids = CONCAT_WS(',',ids,tempid); 10 select ParentId into tempid from department where id=tempid; 11 end while; 12 return ids; 13 end
GROUP_CONCAT
把某个字段的数据显示到一列以逗号隔开
REPLACE
替换
标签:set,int,ids,tempid,语法,Mysql,id,CONCAT From: https://www.cnblogs.com/huodetiantang/p/17337266.html