Checking for fields not on SET clause on before update trigger on MySQL
flag will be what it had been before the UPDATE started.  Maybe it would feel 'right' to use OLD.flag instead of NEW.flag, at least in the if?

Addenda

NEW.flag contains the new value. NEW.flag &lt;=&gt; OLD.flag checks to see if it changed. I doubt if there is any way to see if it was set but not changed. (Note that I used the "NULL-safe equal" operator.)