I just want to replace (update) DATE, PRICEand OLDPRICEwhen the price is different from the PRICE in my table, where it MODELis unique.
Example row table data:
DATE | MAKE | MODEL | PRICE | OLDPRICE
2012-04-15 | Advance | DTA-100-X | 400 | 390
There should be dozens of ways to do this, but I'm looking for the best solution to use in a MySQL query.
Should I use:
INSERT INTO..ON DUPLICATE KEY UPDATEREPLACE INTO..UPDATE...WHERE PRICE != XXX
The essential syntax will be UPDATEif it is the MODELsame, but PRICEdifferent; OLDPRICEbecomes PRICEonUPDATE
* UPDATE *
This REPLACES whether the price has changed or not. I only want updates / replacements when the price changes, i.e. This should NOT update anything above, but this is because the date is different:
REPLACE INTO MyTable (DATE, MAKE, MODEL, PRICE, OLDPRICE) VALUES ('2012-10-02', 'Advance', 'DTA-100-X', '400', '390')
Toddn source
share