NYCPHP Meetup

NYPHP.org

[nycphp-talk] TRUNCATING MySQL FIELDS

PaulCheung paulcheung at tiscali.co.uk
Sat Jul 28 13:49:24 EDT 2007


I created a MySQL database with tables. In one of the tables, the Customer 
Name& Address table, I use as the PRIMARY KEY a numeric field that I call 
LICENCE which is a number generated through a random number generator.

When I set the table up I set the LICENCE to INT(8). When populating this 
field I was expecting any number larger than 8 digits to be truncated and 
any number less than 8 digits to be padded out with zeros, in both cases 
this is not happening. LICENCE is being populated with a random number of 
varying size returned from the random number generator. sometimes 9 digits, 
8 digit, 7 digits and so on; but each time a unique number. I thought INT(8) 
meant an interger of 8 digits long, no more and no less. Does anybody know a 
way around this?

Paul



More information about the talk mailing list