1

I am using this query

LOAD DATA LOCAL INFILE 'Base.txt' INTO TABLE my_data 
CHARACTER SET latin1 
FIELDS TERMINATED BY '\t' 
ENCLOSED BY '"' 
LINES TERMINATED BY '\r\n' 
IGNORE 1 LINES

To insert the data into the my_data table works great, the problem is how to implement the following with the LOAD DATA MYSQL QUERY.

Condition 1: IF the column SKU in the CSV file MATCHES with the column SKU in the my_data table THEN UPDATE column NEW_FLAG=1 in the database.

Condition 2: IF the column SKU in the CSV file DOES NOT MATCH with the column SKU in the my_data table THEN INSERT the records as it is.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
david.adam
  • 57
  • 4

0 Answers0