Naterade
Naterade

Reputation: 2675

Mysql is truncating char(2) column values to 1 character

I have a database of zipcodes in this format:

zip varchar(11)     
state char(2)                       
latitude varchar(10)            
longitude varchar(10)               
city varchar(50)                
full_state varchar(50)      
is_active tinyint(1)    

I am importing a csv file into it. Everything loads fine except for the state(2) field which instead of loading say, MA or NY, it just loads it as one character, M and N. I am using a mysql myisam table and using the PHPAdmin import feature. Any ideas on the possibilities causing this?

If you need more info let me know and thanks in advance!

Upvotes: 0

Views: 103

Answers (1)

seanbreeden
seanbreeden

Reputation: 6097

Check to ensure that your csv file doesn't have spaces around the state field. For example, it should be like this:

Cincinnati,OH,45241,USA

and not

Cincinnati, OH, 45241, USA

If you could paste a few lines of your file it would help diagnose the problem.

Upvotes: 4

Related Questions