CodeIgniter Forums
mysql affected column in mysql trigger - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: mysql affected column in mysql trigger (/showthread.php?tid=23581)



mysql affected column in mysql trigger - El Forum - 10-15-2009

[eluser]Skuja[/eluser]
Has anyone been dealing with MySQL triggers ?
I have a problem. I am creating a trigger for a table so that on updating a field value, all the other fields will be updated... I can't figure out how to check which in which column field is affected while on table update.
Hope someone could help me with this one.


mysql affected column in mysql trigger - El Forum - 10-15-2009

[eluser]davidbehler[/eluser]
Have you looked here?

I don't think there is a function that tells you wether a field has changed or not, but you should be able to compare the new and the old value:
Code:
if(NEW.column == OLD.column)
  //do something
or something similar...I'v not yet worked with triggers