homepage Welcome to WebmasterWorld Guest from 54.166.255.168
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
mysql column type for numeric values
Imaster

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3345288 posted 12:00 pm on May 21, 2007 (gmt 0)

Hello,

I have a mysql table which has a column which always uses a ten digit number. This number may be in the following formats: "0011223344" or "1122334400", etc

I used the varchar datatype earlier for this column but since the searches are done using this column, I decided to use either numeric or bigint for this column. But if I change it to bigint or numeric (10,2) - then it removes the starting 0's. For example: "0011223344" becomes "11223344".

However the search for "0011223344" or "11223344" provides the same results.

I would like to use the fastest column type to speed up searches and "0011223344" should display as "0011223344" within mysql.

 

IndiaMaster

5+ Year Member



 
Msg#: 3345288 posted 12:09 pm on May 21, 2007 (gmt 0)

Hi,

You should choose column type as BIGINT and set its ATTRIBUTE to "UNSIGNED ZERO FILLED".

Hope, you will get the desired result.

Imaster

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3345288 posted 12:15 pm on May 21, 2007 (gmt 0)

Wow, IndiaMaster. That works perfect. thanks a ton :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved