php - How to update table using LOAD INFILE?
$this->db->query("LOAD DATA LOCAL INFILE '".$file_path."' INTO TABLE table1 CHARACTER SET utf8mb4 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES (Email,Jurisdiction_Parish,Jurisdiction_Ward,Jurisdiction_Precinct,Personal_FirstName, Personal_MiddleName,Personal_LastName,Personal_NameSuffix,Residence_HouseNumber,Residence_HouseFraction,Residence_StreetDirection, Residence_StreetName,Residence_ApartmentNumber,Residence_City,Residence_State,Residence_ZipCode5,Residence_ZipCode4,Mail_Address1, Mail_Address2,Mail_City,Mail_State,Mail_ZipCode5,Mail_ZipCode4,Mail_Country,Personal_Sex,Personal_Race,Registration_PoliticalPartyCode, Personal_Age,Registration_VoterStatus,Registration_Date,Registration_Number,Personal_Phone,LastVoted,Residence_WalkListOrder, Favorability,Yard_Sign,Comments,Personal_NameOrder,voted,Rating,Custom_Variable1,Custom_Variable2,Custom_Variable3) SET cid =".$cid.", csvsheet_id=".$csvsheet_id );
The above code for insert the data of CSV into database but i want to update the existing records of database from CSV. So How can i modified the query so that it will work for UPDATE the records.
i used the below code for update the existing records of database.
But the problem is that in my CSV file i have only two column. When I Run the query it Updated the Records(voted column only) but others column has been blanked. Is is necessary to give all the column name with the data also..??