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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:09:28+00:00 2026-06-04T03:09:28+00:00

I have two tables, projects and archive with identical columns. As you understand, I

  • 0

I have two tables, projects and archive with identical columns. As you understand, I need to archive projects in the archive table, under certain conditions.

I wrote two requests, and they work fine if executed separately, but I’d like to assemble them.

$sql = "INSERT INTO archive (idDocument,documentNumber,submissionDate,projectName)
        SELECT idDocument,documentNumber,submissionDate,projectName
        FROM projects
        WHERE id='".$id."'";

$sql = "DELETE FROM projects
        WHERE id='".$id."'";

1/ First of all, how can I assemble these two requests? I keep getting syntax errors.

2/ Now, I assign projects a status (in a column named status) from “1” to “3” in PHP and I’d like to archive these projects two months after they have reached status “3”. How can I do so?

Thank you very much for your help.

  • 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-04T03:09:29+00:00Added an answer on June 4, 2026 at 3:09 am

    Do not know what You mean by assembling, maybe You want to query these two queries in just one simple call, then each query should be ended by query delimiter – a semicolon ;, like this:

    $sql = "INSERT INTO archive (idDocument,documentNumber,submissionDate,projectName)
        SELECT idDocument,documentNumber,submissionDate,projectName
        FROM projects
        WHERE id='".$id."';
    
        DELETE FROM projects
        WHERE id='".$id."';";
    

    If You want to archive+delete the projects with status 3 after two months they had been statused by 3, You will have to do these things:

    1. when updating the project to status 3 also set the date_changed = NOW() (or similar expression)
    2. write down a CRON job that will be executed let’s say every day at 3:00 am.
    3. the CRON job will call a PHP script that will walk down the projects table and archive + delete all the projects with status 3 where date_changed is less then or equal to NOW() - INTERVAL '2' MONTHS…

    That should do the trick…

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

Sidebar

Related Questions

I have two tables, users & projects users table: id username 1 sam 2
I have two tables: entitytype and project . Here are the create table statements:
I have two tables : teachers (teacher_id,teacher_name) courses (teacher_id,course_id) And I need to display
I have two tables: 1. tableA is a list of records with many columns.
I have two tables an employee table and a project table and I am
I have two projects using legacy databases with no associations between the tables. In
I have two tables: one called Projects, and another called Documents (projects has many
I have two tables in my rails application Categories and Projects. The relationship between
I have two tables: Projects and ProjectsData and I want to execute query with
I have two tables: projects and user_licenses . I'd like to grab the entire

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.