It is currently Sat Feb 04, 2012 3:41 pm

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: keeping a 0 in front of a random integer
PostPosted: Tue Apr 22, 2008 4:39 pm 
Offline

Joined: Tue Apr 22, 2008 4:34 pm
Posts: 1
Hi, I have a minor problem with keeping the 0 in front of an integer whenever i insert it into a field.

i.e.

inserting a number such 0123 would be stored as 123 in INT datatype field.


how would i get around to keeping the 0 because its crucial in the work i'm doing. thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 22, 2008 8:24 pm 
Offline

Joined: Sun May 02, 2004 11:34 pm
Posts: 6498
Location: toronto, canada
1. make the field a character field (char or varchar) and understand that its a string now

2. handle it in the php code before displaying

_________________
Lostboy

Cat, the other other white meat

Please read Posting Etiquette before posting

You can always try Google


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 27, 2008 12:09 pm 
Offline

Joined: Sat Mar 22, 2008 9:04 pm
Posts: 33
you need to make the column ZEROFILL.
Code:
ALTER TABLE table_name CHANGE column_name column_name INT( 11 ) UNSIGNED ZEROFILL NOT NULL

_________________
Linux, Apache, MySQL, PHP


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron