CREATE DEFINER=`root`@`localhost` FUNCTION `deleteManyChar`(in_str varchar(2000)) RETURNS varchar(2000) CHARSET utf8 COLLATE utf8_unicode_ci
BEGIN
DECLARE v_result VARCHAR(2000);
DECLARE v_strs VARCHAR(2000);
DECLARE v_obj VARCHAR(2000);
IF (in_str is not null) THEN
SET v_strs = in_str;
while INSTR(v_strs,',') > 0 do
SET v_obj = SUBSTR(v_strs, 1, INSTR(v_strs, ','));
SET v_strs = SUBSTR(v_strs, INSTR(v_strs, ',') + 1);
if(v_result is null) THEN
SET v_result = v_obj;
else
IF(INSTR(v_obj, 'NULL') = 0) THEN
if(INSTR(v_result, v_obj) = 0) THEN
SET v_result = CONCAT(v_result,v_obj);
end if;
end if;
end if;
end while;
ELSE
SET v_result = in_str;
END IF ;
RETURN left(v_result,LENGTH(v_result)-1) ;
END