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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:28:40+00:00 2026-06-10T19:28:40+00:00

well, I have a script which processes some data, and then it imports it

  • 0

well, I have a script which processes some data, and then it imports it in a mysql database.

Then, I also have another script which processes some other data, and then it also imports it in a mysql database.

What I want to do:

I want with a 3rd script to control (e.g., see how many rows were last imported) only the rows that were imported with the last script. Not these imported by the first (but i don’t want the first imported rows to be deleted to have only those last imported).

Is there some way in MySQL or PHP for that?

If i’m unclear about something tell me.

Thank you in advance!

  • 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-10T19:28:41+00:00Added an answer on June 10, 2026 at 7:28 pm

    You could always add a last_import column to your database. Every time your script imports something to a mysql database, before it imports, it changes all the values of last_import to no or something similar, then inputs its rows with a value of yes or something similar. Using this method, you can easily tell which ones were last imported.

    Say this is your database:

    -----------------
    |  id  |  name  |
    -----------------
    |   1  |  Simon |
    -----------------
    |   2  | Richard|
    -----------------
    |   3  |  Jon   |
    -----------------
    

    Add this field:

    -------------------------------
    |  id  |  name  | last_import |
    -------------------------------
    |   1  |  Simon |     N       |
    -------------------------------
    |   2  | Richard|     N       |
    -------------------------------
    |   3  |  Jon   |     N       |
    -------------------------------
    

    So if you’re using mysql (tell me if you aren’t), do this every time you insert and process your data:

    // Process data before here
    $query = "UPDATE thetable SET last_import = 'N'"; // Changes all values of last_import in table to N
    $result = @mysql_query($query) or die (mysql_error());
    $query = "INSERT command here"; // do your inserting, while inserting the rows, put Y as the value of the last_import.
    

    Then in your final checking file:

    $query = "SELECT * FROM thetable WHERE last_import = 'Y'"; // Selects all that was last imported
    // Process the query here
    

    That should work.

    UPDATE: Thanks to Gavin’s suggestion (Thanks Gavin!) I also suggest using a timestamp value. This would work like this:

    Your table will be like this:

    -------------------------------
    |  id  |  name  | last_import |
    -------------------------------
    |   1  |  Simon |  1346748315 |
    -------------------------------
    |   2  | Richard|  1346748315 |
    -------------------------------
    |   3  |  Jon   |  1346748315 |
    -------------------------------
    

    And in your insert queries:

    // Process data before here
    $currenttimestamp = time();
    $query = "INSERT command here"; // do your inserting, while inserting the rows, put $currenttimestamp as the value of the last_import.
    

    And when selecting:

    $query = "SELECT last_import FROM thetable ORDER BY last_import DESC LIMIT 1"; // Selects the most recent timestamp
    $result = @mysql_query($query) or die (mysql_error());
    $mostrecenttstmp = @mysql_result($result, 0);
    $query = "SELECT * FROM thetable WHERE last_import = '$mostrecenttstmp'";
    // Process the query here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script which, given an ID, kicks off some complex processes and
I have a PHP search script which I've altered slightly and works well for
hi this is the script i have, it works well to search my database.
Well, the title say it all. I have a ruby script I want running
Scenario: I load some data into a local MySQL database each day, about 2
I have a script working well for creating ad hoc iPhone builds. I can
I have the following script that works well in Firefox and Chrome (not sure
As the title suggests, I've inherited a php/MySQL application which has fairly well written
I have a script that is trying to compare specific data based on a
Background: I'm working a project which uses Django with a Postgres database. We're also

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.