MySQL 5.1.41 leading zero is deleted

mysql

Solution

You should probably store phone numbers as a `varchar`. Phone numbers are only numeric by accident.

You may also be interested in checking out the following Stack Overflow posts:

- What datatype should be used for storing phone numbers in SQL Server 2005?

- Common MySQL fields and their appropriate data types

Problem

I have a MySQL database where I want to store phone numbers among other things. The fieldtype is INT(10) When I try to insert a number starting with a 0, like 0504042858 it's stored like 504042858. This only happens with phone numbers with leading zeros. When the number start with any other number, it's stored correctly. What am I doing wrong?

Original source

Related problems