I have a csv file having 5 columns and i want to load only one out of that, is there a way i can do it. I want to use LOAD statement of MySQL 5.5 Any pointers are welcomed, help would be much appreciated
From the documentation:
You can also discard an input value by assigning it to a user variable and not assigning the variable to a table column:
LOAD DATA INFILE 'file.txt' INTO TABLE t1 (column1, @dummy, column2, @dummy, column3);
you can save the csv field value to a variable and assign the variable to the table field.
load data infile 'filelocation../file.csv' into table myTable columns terminated by ',' optionally enclosed by '"' escaped by '"' lines terminated by '\n'(@value1,@value2,@discardValue,@value4) set f1=@value1 ,f2=@value2,f3=@value4;