TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Zeros in query? (http://www.talkphp.com/general/1263-zeros-query.html)

marxx 09-30-2007 07:15 PM

Zeros in query?
 
Hi, just notice that if I add like zip code into my database (ie. 00650 or 01250). First zeroes won't be inserted in field.. Why? and most important, how can I fix that?

Beginners stuff I know but this is first time I actually have to face this matter! ;)


Thanks for all help.

Karl 09-30-2007 07:24 PM

When your adding the column simply specify zerofill, such as:

Code:

post_code int(6) zerofill default NULL

marxx 09-30-2007 08:55 PM

Thanks Karl but doesn't work.. ?

Still, if number is like 00650 it's going to be there as 650 .. First two zeros won't be added.. bummer! :/

Wildhoney 09-30-2007 11:45 PM

Zerofill should have done it, but something like:

Code:

INSERT INTO
        myTable
        (myColumn1)
VALUES
        (LPAD(00650, 5, 0))



All times are GMT. The time now is 10:41 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0