Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

Trigger to UPDATE after UPDATE?

Use a BEFORE trigger instead, and set the updated column assigning a value to NEW.updated (this would be a simple assignment, not an UPDATE). This way you won't trigger additional UPDATEs.

Your trigger body will simply look like

SET NEW.updated = NOW()

I usually use AFTER triggers only for modifying other tables, BEFORE for modifying the new (or updated) row, or suppress DELETE.

Tags:

Mysql

Trigger

Update

Row Modification Time

Related

Create function in central database or repeat in each database? MySQL Set UTC time as default timestamp Daily database maintenance using SQL Server 2008 and a stored procedure How does SQL Server choose an index key for a foreign key reference? Possible to keep max number of records in postgresql? Parameter sniffing work arounds Dynamically Define a Range in a Dimension SQL Server how to get around the transaction log filling up when updating a column to an int Suppress SQL Server Management Studio auto complete Why can't this mysql user log in with password? How to compare two SQL Server 2008 configurations How to log error details when using using try/catch for dynamic SQL backup commands

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy