Hi all,

I've problem with inserting data values from .csv file to MySQL data table.

My query as follows;

LOAD DATA INFILE 'C/Customers.csv'
INTO TABLE pc.customers
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(CustID, RegDate, CName, CAddress, CPhone1, CPhone2, Order_OrderID) 

It returns error msg as follows;
Error Code: 1406. Data too long for colum "CustID" at row 1.

FYI, my CustID datatype is varchar(255) and one of its data value is "C001". I'm using MySQL workbench.

Anyone pls help.. Thx

It could be a quoting issue in your data. Hard to see without the table structure and test data.

My Table structure as follows;

CustID - varchar(255) PK, NN, UQ
RegDate - Date NN
CName - varchar(45) NN
CAddress - varchar(45) NN
CPhone1 - INT NN
CPhone2 - INT
Order_OrderID - varchar(45) NN

My Sample data values as follows;
CustID - C001
CName - Marly
CAddress - R. Sete de Setembro 54
CPhone1 - 89875477
CPhone2 -
Order_OrderID - O12365, O12375, O12376

Anyway, is it because of mysql server setting?

I've had data that had a ' in it a few times, and that caused me problems. I loaded the csv file into Excel, and saved it as text, tab delimited and the problem went away instantly. I've stuck to that method and delimiter ever since.