如何去掉mysql中小数多余的0
2017-08-18
展开全部
写个函数 自己调用处理就行了
CREATE FUNCTION `NewProc`(format_vale VARCHAR(100))
RETURNS varchar(100)
BEGIN
DECLARE dec_number VARCHAR(4000);
DECLARE dec_number_vale VARCHAR(4000);
SET dec_number = '';
SET dec_number_vale = CAST(format_vale AS CHAR);
WHILE dec_number_vale IS NOT NULL DO
-- 剪切字符串
SET dec_number = right(dec_number_vale,1);
IF dec_number = '0' || dec_number= '.' THEN
SET dec_number_vale = LEFT(dec_number_vale ,LENGTH(dec_number_vale)-1);
ELSE
RETURN dec_number_vale;
END IF;
END WHILE;
END;
CREATE FUNCTION `NewProc`(format_vale VARCHAR(100))
RETURNS varchar(100)
BEGIN
DECLARE dec_number VARCHAR(4000);
DECLARE dec_number_vale VARCHAR(4000);
SET dec_number = '';
SET dec_number_vale = CAST(format_vale AS CHAR);
WHILE dec_number_vale IS NOT NULL DO
-- 剪切字符串
SET dec_number = right(dec_number_vale,1);
IF dec_number = '0' || dec_number= '.' THEN
SET dec_number_vale = LEFT(dec_number_vale ,LENGTH(dec_number_vale)-1);
ELSE
RETURN dec_number_vale;
END IF;
END WHILE;
END;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询