Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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

share|improve this question
2  
This is covered in the documentation –  Kermit May 15 '13 at 15:28

1 Answer 1

up vote 6 down vote accepted

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);
share|improve this answer
    
I have gone through the documentation, but i have a csv file say - 46,94,43,12 now i want to discard the third column, LOAD DATA INFILE 'file.txt' INTO TABLE t1("WHAT SHOULD I WRITTE HERE?? THE COLUMN NAMES??)... Thanks for your time Phil.. –  Hitesh Chouhan May 16 '13 at 4:54
    
LOAD DATA INFILE 'file.txt' INTO TABLE t1 (column1, column2, @discard3, column4); –  Phil May 16 '13 at 5:02
    
Thanks a lot phil.. –  Hitesh Chouhan May 16 '13 at 5:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.