MySQL field structure

I have an integer field of a MySQL table data type. the value is saved as 1, 2, 3 .., 10000.

I want to format it starting from 00001, 00002, 0003, etc. (integer should be 5 digits).

Is there any function?

or how to install it manually in phpMyAdmin ..

+3
source share
1 answer

You can change the column type to INT (5) ZEROFILL. From the documentation :

When used in conjunction with the optional ZEROFILL extension attribute, gaps are replaced with zeros by default. For example, for a column declared as INT (5) ZEROFILL, a value of 4 is obtained as 00004.

Example:

CREATE TABLE table1(x INT(5) ZEROFILL);
INSERT INTO table1 VALUES(4);
SELECT * FROM table1;

Result:

00004
+5
source

Source: https://habr.com/ru/post/1758735/


All Articles