Is there a MySQL equivalent of sprintf?

前端 未结 3 493
轮回少年
轮回少年 2021-01-17 08:05

I have an INT field in my table, which I\'d like to select as a zero-padded string. So for example, 8 would come out as 008, 23 as 023 and so on. I

3条回答
  •  误落风尘
    2021-01-17 08:23

    Depending on the version of mySql you have, you could define a UDF that would format the value for you. see http://dev.mysql.com/doc/refman/5.1/en/adding-functions.html.

提交回复
热议问题