mysql insert update LOAD DATA LOCAL INFILE -
i using load data local infile load data temp table mid.then use update query update found in table product.the matching field in both model.
$q = "load data local infile 'mid.csv' table mid fields terminated '\t' lines terminated '\n' ignore 1 lines (@col1,@col2,@col3,@col4,@col5,@col6) set model=@col1,price=@col3,stock=@col6 "; mysql_query($q, $db); mysql_query('update mid m, products p set p.products_price= m.price,p.products_quantity= m.stock p.products_model= m.model');
it works , update product table.the issue having there new records in mid table don't inserted using update statement.
i have looked @ insert query , update on duplicate.i have seen loads of examples of when has work on 1 table none have match against table.
either searching wrong thing or there way to this.
i appreciate help.
regards
naf
i'm not sure other columns in product table are, here's basic approach should work based on 3 columns in example, assuming products_model column unique in products table:
insert products (products_price,products_quantity,products_model) select price, stock, model mid on duplicate key update products_price = values(products_price), products_quantity = values(products_quantity)
Comments
Post a Comment