Home > Mobile >  MySQL Trigger Before Update New vs Old
MySQL Trigger Before Update New vs Old

Time:10-17

I need help adjusting a before update trigger to recognize when the previous value changes, including from NULL and BLANK.

If NEW.column_1 <> OLD.column_1 then…….

I think I can use <=> to check if the previous value was NULL but what about when it changes from blank?

Travis

CodePudding user response:

The <=> operator does test if a blank value is equal to a non-blank value.

mysql> select '' <=> 'notblank' as same;
 ------ 
| same |
 ------ 
|    0 |
 ------ 
  • Related