Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8885873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:25:08+00:00 2026-06-14T21:25:08+00:00

I have a simple DB-table with few fields for articles database among that is

  • 0

I have a simple DB-table with few fields for articles database among that is a TimeStamp containing the time of the last update made on the article.

I use “ON UPDATE CURRENT_TIMESTAMP”

Problem is that I want to update only if some fields of this record have changed, not all.

i.e. For each article, I have a field giving the number of time the article has been read by visitors. must not be updated after each web visit… only if I change the title, authors, etc…

Ideally with a nice mysql command…


I have coded the following:

CREATE TRIGGER `actu_lastupdate_date` BEFORE UPDATE ON `actuality`
 FOR EACH ROW BEGIN
    if NEW.title <> OLD.title OR NEW.chapeau = OLD.chapeau OR NEW.content = OLD.content
    then
        SET NEW.LastUpdate_date = current_timestamp;
    end if;
END

it seems that even if another record field is changing, the Timestamp is updated. There should be something bad somewhere.
I’ll look into it

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:25:09+00:00Added an answer on June 14, 2026 at 9:25 pm

    You could write a trigger to add the timestamp on updates

    delimiter |
    CREATE TRIGGER actu_lastupdate_date AFTER UPDATE on actuality
    FOR EACH ROW
    BEGIN
        if (NEW.title <> OLD.title 
             OR NEW.chapeau <> OLD.chapeau 
             OR NEW.content <> OLD.content)
            AND (NEW.other_column = OLD.other_column 
             OR NEW.other_column2 = OLD.other_column2)
        then
            SET NEW.LastUpdate_date = current_timestamp;
        end if;
    END
    |
    delimiter ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL database that has a few very simple tables. I would
I have a few simple entities that are stored in a simple code table
I have a simple table that has this structure: <table> <thead> <tr> <td>Some info</td>
I have a simple table (lets call it Table1) that has a NVARCHAR field
I have a simple contact form on a website that has 2 text fields,
I have a fairly simple database that I inherited. For the purposes of this
I have a table in my database with a lot of fields. Most of
I have a MySQL 5.0 database with a few tables containing over 50M rows.
I have simple table in Sybase -- Creating table 'SimpleText' CREATE TABLE [dbo].[SimpleText] (
I have simple table creating script in Postgres 9.1. I need it to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.