I have a table to which I upload data from CSV files.
The fields are like the following:
StudentName | SubjectName| Result
---------------------------------
Adam | Math | Fail
Bob | History | Pass
Catherine | Math | Pass
Dave | Science | Fail
Evan | History | Pass
Primary key here is (StudentName,SubjectName)
I use the following code to get the data into the table:
Load data local infile 'C:\\Test.csv' INTO TABLE test_table
Fields terminated by ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '"'
Lines terminated by '\n'
ignore 1 lines;
There are more than one csv files that I need to import. There could be possible key duplicates. I am trying to update a certain field when a duplicate is encountered.
i.e.: If there is a duplicate, UPDATE field RESULT if : value for result in the duplicate entry is "Pass".
Each csv file would be for each day the tests are conducted.
If the student gets a pass at least once, the table should reflect that.
How should I change my code to make this happen?