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 8533289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:55:46+00:00 2026-06-11T09:55:46+00:00

How can I update a table after some time interval when a condtion is

  • 0

How can I update a table after some time interval when a condtion is matched?

tb_contest
id   contest_id   name   is_expire
1    101          new    0
2    102          old    0

tb_answer
contest_id   answer_id   date
101          1           2012-02-02
101          2           2012-09-14
102          5           2012-06-01

I need to update tb_contest after some condition was met and make is_expire=1 after 2 days on basis of the last answer received i:e 2012-03-14, so the tb_contest should be updated on 2012-09-16.

  • 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-11T09:55:47+00:00Added an answer on June 11, 2026 at 9:55 am

    Try this one,

    UPDATE tb_contest a INNER JOIN
            (
                SELECT contest_ID, MAX(`date`) maxDate
                FROM tb_answer
                GROUP BY contest_ID
            ) b ON a.contest_ID = b.contest_ID
    SET a.is_expire = 1
    WHERE   DATEDIFF(CURDATE(), b.maxDate) >= 2 AND 
            a.is_expire = 0
    

    So here it goes, the two tables were joined by contest_ID and having the lastest answered date on tb_answer. By using DATEDIFF() we can know the difference between today’s date and the date the contest has been answered.

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

Sidebar

Related Questions

Does this mean I can't update another table from a trigger if I'm using
How can we update timestamp in table without any updation without below statement update
can i use GROUP_CONCAT to update table? I have 2 tables i d |
I am trying to figure out how can I update the petevents table with
How can one update an attribute value in DynamoDB table to ? one option
how can i write the query, to update the table videos , and set
I use this code to update data in database table. Can reuse same code
Merge can performs insert, update, or delete operations on a target table based on
I'm trying to use a4j:poll component for ajax reloading a datatable after some time
I have a table which need new column. The newly introduced column need some

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.