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

  • SEARCH
  • Home
  • 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 7487943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:41:48+00:00 2026-05-29T14:41:48+00:00

How can I use trigger to simply update a table with the last time

  • 0

How can I use trigger to simply update a table with the last time a table was edited? I know that by using triggers it is “for each row” but if someone’s inserting more than one row, it’d be pointlessly inserting or altering the table over and over again. Is there any way to do this without doing it over and over again?

I’d like to be able to just have it do it once for all of the inserts instead of having it done time and time again. If not I guess I can force it, via a wrapper.

edit 1:
Well to explain some more of the design I guess then.

I’m going to be having a table in another database to handle the last_updated data for things like chat, or the players “mailbox”, and another one for the development things like tables for quests, skills, items etc. And I want to be able to know when a table was last updated so that I can easily see before I go scan the table to see for new things.

Basically this is what I’d like to do(or something similar), I’m also using PHP so it’s likely to be PHP-based approach in the code but the SQL should be kind of standard. I’m not going to do full code but rather semi-runnable.

last_modified=mysql_query("select last_modified from various_stats.table_last_updated where database_name=`database_name` and `table_name`");
if(last_modified>last_checked_time){
        data_to_get_updated=mysql_query("select something from various_<something>.table_name where last_modified>last_checked_time");
}
else{
     do_nothing;
}

edit 2: I’m using InnoDB, and thus I cannot use the information schema’s update_time since it never changes.

  • 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-05-29T14:41:49+00:00Added an answer on May 29, 2026 at 2:41 pm

    will this help you, if im on the right track that is:

    SELECT UPDATE_TIME
    FROM   information_schema.tables
    WHERE  TABLE_SCHEMA = 'dbname'
    AND TABLE_NAME = 'tabname'
    

    The above solution is for myisam, for innodb the norm is to set a sceduled script, this can be set as a cron job or a windows scheduled task, if you dont have that kind of control over your web host, you could possibly set up a small server at your work office and run the cron from there. if you do this every say 20 seconds you could simply record the current top auto incremented ID and use this as a guid, if current ID is higher than the last recorded ID you then update your records to show the last changed time to be now.

    as this will only be one call to a server every XX seconds, it wont really hammer the server too much and should just run silently in the background.

    If you do go down the scheduled task root, it would be wise to add error capture in your script so that you can be alerted via email if something stops working etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When writing a row-level trigger in Oracle, I know that you can use the
I know I can use watch to bind a callback that will be triggered
How can one use Triggers for Logging History of database changes in MySQL? If
I can use VS08's MFC/ActiveX template to create a C++ ActiveX object that I
Someone told me that I need to use a delimiter in my trigger. I'm
I'm trying to use jquery to update a database using .ajax(). The idea is
I am maintaining some code that has a trigger on a table to increment
You can use more than one css class in an HTML tag in current
You can use a standard dot notation or a method call in Objective-C to
I can use properties of an Excel Worksheet to tell if the worksheet is

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.