本篇内容主要讲解“MySQL怎么实现给定数字生成中文数字”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“MySQL怎么实现给定数字生成中文数字”吧!



用MySQL实现

selectgroup_concat(targetorderbyiddescSeparator'')resultfrom(

select

concat(

cases

when0thenif(@lastrow!=0,'零','')

when1then'一'

when2then'二'

when3then'三'

when4then'四'

when5then'五'

when6then'六'

when7then'七'

when8then'八'

when9then'九'

end,

case(id-1)mod4when0then''

when1thenif(s!=0,'十','')

when2thenif(s!=0,'百','')

when3thenif(s!=0,'千','')

end,

case((id-1)/4)when1then'万'

when2then'亿'

else''

end

)target

,

@lastrow:=s

,

a.*

from(

selectvar.n,nums.id,substring(var.n,length(var.n)-id+1,1)sfrom(

select30150000n,@lastrow:=null

)var,numswherelength(var.n)>=nums.id

)a

)b

到此,相信大家对“MySQL怎么实现给定数字生成中文数字”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!