NIDHEESH KRISHNA
NIDHEESH KRISHNA

Reputation: 177

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

Upvotes: 2

Views: 831

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172578

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') 

Upvotes: 1

Related Questions