What I was trying to do is to load a csv file into the database. But I am having a problem because of duplicate entry.
I am using PHP script to load the file.
$sql = "LOAD DATA INFILE '" . $target_path;
$sql.= "' INTO TABLE dummy ";
$sql.= "COLUMNS TERMINATED BY ','";
$sql.= "OPTIONALLY ENCLOSED BY '\"'";
$sql.= "ESCAPED BY '\"'";
$sql.= "LINES TERMINATED BY '
'";
$sql.= "IGNORE 1 LINES;";
Database Table Structure:
id | firstname | lastname
CSV File content..
id | firstname | lastname
1 John Doe
2 James Carry
3 Luke Borrow
As expected 'id' is the primary key. Is there a way to skip values that violates primary key constraint on the fly?