NIDHEESH KRISHNA NIDHEESH KRISHNA - 7 months ago 36
SQL Question

Allow number to start with ZERO when stored in mysql text field

I need to store phone numbers starting with 0 but whenever i try to store this in MySql table the starting ZERO is removed because no number start with Zero actually
how i can solve this problem please do i need to change the field type from Integer to another type

Answer

Try to change the datatype to unsigned-zerofill. Refer the manual.

or you can use the LPAD function as well like

SELECT LPAD( yourNumber, lengthOfYourNumber, '0')