mysql - How to do update with LOAD DATA LOCAL INFILE without using temporary table -


i'm using below query update fields in table

load data local infile '$_file' replace table test_db.productsinfo fields terminated '\,' optionally enclosed '\"'   ignore 1 lines  (\`products_id\`,   \`products_source\`,   \`quantity\`,   \`cost\ )  

but,replace deletes entire row , put's new 1 ,which not kind of update require. unfortunately cant use temporary table due speed issues. there anyway achieve function of on duplicate update in case ?

this long comment.

if need real-time updates table in database, sql has nifty statement, called update. in seriousness, should update explicitly , not pass values through file, if speed primary concern.

your application has taken time hit of putting data file , (presumably) waiting writes file completed. additional time load data table update part of process of "creating file".

there may ways speed update. instance, after loading temporary file, create index on toupdate(product_id). should speed query of form:

update products p join        toupdate        on p.product_id = toupdate.product_id     . . .  

Comments