将-1 的值返回空串
DELIMITER $$
CREATE FUNCTION `nagetiveTo`(r int(10)) RETURNS char(10) CHARSET utf8
BEGIN
DECLARE fra char(10) DEFAULT '';
set fra=(case when r=-1 then '' else r end);
RETURN fra;
END$$
DELIMITER ;
将字典表里面的id转换成name
DELIMITER $$
CREATE FUNCTION `getDisc`(rrrr int(10)) RETURNS varchar(255) CHARSET utf8
BEGIN
DECLARE fragmentHot VARCHAR(255) DEFAULT '';
set fragmentHot=(SELECT `name` from dict_base_info where id=rrrr);
RETURN if(fragmentHot is null,"",fragmentHot);
END$$
DELIMITER ;