SQLite function to format numbers with leading zeroes?

后端 未结 4 2036
清歌不尽
清歌不尽 2020-12-29 20:22

I’ve got an SQLite database that will need to contain products. Those products have a fixed-format composite product number, consisting of category, group and product numbe

4条回答
  •  暖寄归人
    2020-12-29 21:15

    I know this is an old question, but the following is simpler:

    --  zero-pad to 4 digits:
    select substr('0000'||3,-4);
    

    substr does not require a length if you’re selecting to the end.

提交回复
热议问题