MySQL query to load data from file
Posted on 2014-01-27
I have the following mysql query written in a java spring application to load data from file
into the table :
"LOAD DATA LOCAL INFILE '"+ dumpFile.replace("\\", "\\\\") +
"' REPLACE INTO TABLE "+ table
+" FIELDS TERMINATED BY '\\t' LINES TERMINATED BY '\\n'"+
" (origin, destination, price, dep_date, arrival_date, supplier, search_type)";
Now the table structure to which the data is being loaded have an extra column called key.
And that extra column is key = origin#destination#dep_date
but if search_type='R'
then key = origin#destination#dep_date#arrival_date
Now i need to insert this key too.
How do i modify my query to do this ?