如何在mysql中的int之前添加零

I have Mysql table which include zip code and it is int.

The problem is when I insert a zip code begin with 0 " 0123" it saves like "123" without zero.

How to solve it in mysql structure ?

regards

Don't store the zip codes as int.

Storing the zip-codes as varchar(10) or something like that will keep your zero padding and also cater for alphanumeric zip codes which may be used in some areas.

You could change your zip_code field data type to something like varchar:

ALTER TABLE table_name MODIFY column_name VARCHAR(6);

Or if you prefer to keep it as an integer and fill it with leading zeros you can use ZEROFILL:

ALTER TABLE table_name MODIFY column_name INT(6) ZEROFILL;

e.g. 123 becomes 000123, 1234 becomes 001234 etc.. (depends on length)