load csv file content into mysql table with validation -
i want import large csv file (about 12mo) mysql table , first tried load data infile work , in case want firstly test csv rows determine if want update data or insert new records solution read file , compare content of each row data in table , , make right action methode works takes lot of time , resources
now question
1 : can use import functions of phpmyadmin ( open source ) , project comercial
2 : if yes can , know tutorials ( idea )
3 : if no can't , there such commercial frameworks exporting/importing
thanks
this pretty common sql: either want insert or update, yes? need 2 statements (one update, 1 insert) , way tell if should inserted. need unique key never duplicated individual record (can composite key) , 2 statements, this:
update right set right1 = left1, right2 = left2, etc the_import_table right left join the_existing_data left on left.key = right.key right.key not null --note write in tsql insert right ( right1, right2, etc ) select left1, left2, etc left left join right on left.key = right.key right.key null
note can use composite keys using set of anded values in where, , note you're not updating composite keys inserting composite keys. should start. before ask clarification update question actual code.
Comments
Post a Comment