smoothcat11
asked on
Leading Zeros Zip Code MySQL
Hello, I imported a database and concatenated it. It has over 150,000 records.
Every record has a zip code
Every zip code w/ a leading zero has deleted the zero and I just realized it.
Is there a way to fix this w/ our importing the database again?
Example:
07030 is in the database as 7030
I could do a php script to check strlen and then if not 5 add leading zeros until it is 5, but I would like it to be right in the database.
Can you help? Thanks.
Every record has a zip code
Every zip code w/ a leading zero has deleted the zero and I just realized it.
Is there a way to fix this w/ our importing the database again?
Example:
07030 is in the database as 7030
I could do a php script to check strlen and then if not 5 add leading zeros until it is 5, but I would like it to be right in the database.
Can you help? Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Change the field definition from int to char(5), and then a quick one-time change (in php would be trivial to do) to add the leading zero where needed.