How to determine if a row is going to be updated within an update query not using trigger or table definition

49 Views Asked by At

I want to update a column in MySQL only if the row is updated. (meaning all the other values trigger mysql to update the row.)

It's a concatenated text-field, so automatic calculation using ON UPDATE in the table definition won't work. A trigger won't work either since the value is not fixed.

If there is ON UPDATE in table definition or triggers, there must be a way to determine that in some expression, right?

(Of course, I could create/update a trigger every time after the update or do a second update based on automatic update timestamp (which I then need to select first...) but that's both not very effective nor elegant.)

What I'd love to do would be something like this:

UPDATE tbl
SET x = 1, y = 2
ON UPDATE ( z = CONCAT_WS(', ',z,'blah') );
0

There are 0 best solutions below