`tempTable` has two fields `part` and `qty`
`products` also has `part` and `qty` fields and a `last_updated` date stamp.
I wish to UPDATE `products`.`qty` with `tempTable.`qty` and date stamp it
BUT only if the `qty` fields differ.
Straightforward enough
Expand|Select|Wrap|Line Numbers
- UPDATE `products` JOIN `tempTable` USING(`part`)
- SET `products`.`qty` = `tempTable`.`qty`,
- `products`.last_updated` = NOW()
- WHERE `products`.`qty` != `tempTable`.`qty`
Can this be done in one query?
I am sure it can with some combination of IF ELSE / IF EXISTS but I am struggling (just back of holiday)
Two queries is fine but I would prefer one.
Any help appreciated