I have to load set of questions to MYSQL database table.But the table format is like below QNO Questions Option a Option b Option c Option d Rightanswer... but my textfile which i need to load in database using LOADINFILE command is in different format. How can i match my textfile format to my table format?
+1
A:
You can re-map the columns to import in LOAD DATA INFILE.
Check the manual entry
Example:
LOAD DATA LOCAL INFILE '/importfile.csv'
INTO TABLE test_table
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(field1, field2, field3);
I like using a graphical front-end like HeidiSQL to point-and-click the desired fields, and copy the generated SQL from there.
Pekka
2009-12-30 13:56:24
A:
This depends upon your table format, but if there is any complex preprocessing then it's probably a good idea to do it outside of mysql. It's probably a lot easier.
MatthieuF
2009-12-30 13:57:49