Not sure how to ask this but I have a database of products and their prices. The price consist of 3 columns (Current Price, Discounted Price, Previous Price).
I use fgetcsv() to read a CSV of new records then the Mysqli query below to insert or update new records to my database:
$query = "INSERT INTO products (prodname,currprice,prevprice,discprice) VALUES ('$EachRow','$EachRow','$EachRow','$EachRow') ON DUPLICATE KEY UPDATE currprice='$EachRow';";
"UPDATE IF $EachRow<>currprice SET prevprice=currprice,currprice='$EachRow'"
Yes, you can use
IF clause after
Duplicate Key Update
INSERT INTO tbl (name, some_column, some_other) VALUES (username, some_data) ON DUPLICATE KEY UPDATE some_other = IF(some_other > somevalue, lastupdate)
These are called Flow Control Operators