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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:45:44+00:00 2026-05-23T03:45:44+00:00

I need to track changes created in a directory and also saved the history.

  • 0

I need to track changes created in a directory and also saved the history. I have a function that scans the files in that directory then it inserts them in a table. let’s say that the first time this program was run there where files A, and B. As a result the table should look like

FileID     File      DateModified       
  1         A          101010     
  2         B          020202

let’s say the user modifies file B therefore the next time the program runs the table should look like:

FileID     File      DateModified       
  1         A          101010     
  2         B          020202              
  3         A          101010     
  4         B          030303

From looking at the table above we know that file B has been changed because it has a different modified date and also that file A was not modified. Moreover my program know that the records that where inserted are all the records with a fileID greater than 2. How could I perform a select that will return the last file B because that file was modified. I want to be able to know which files have been modified how could I build that query.

Please read above first in order to understand this part. Here is another example.

First time program runs:

FileID     File      DateModified       
  1         X          101010     
  2         Y          020202

Next time program runs:

FileID     File      DateModified       
  1         X          101010     
  2         Y          020202   
  3         Y          020202            
  4         A          010101

so far we know that file X has been deleted because it is not included in the new scan. Moreover we know that file A has been created. And lastly that File Y was not modified it is the same. I would like to perform a select where I can just get the files that where created or modified such as file A in this case.

I am looking for something like:

select * from table1 where fileID > 2 AND File NOT IN (SELECT File FROM table1 WHERE File <=2) AND DateModified NOT IN (SELECT DateModified FROM table1 WHERE File <=2)

I don’t know why is it that when I perform such query I get different results. Maybe I will have to group the File and DateModified into one column to make it work.

  • 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-23T03:45:44+00:00Added an answer on May 23, 2026 at 3:45 am

    I would add a column called scan_number so that you can compare the latest scan with the previous scan.

    SELECT  curr.file, prev.file, curr.DateModified, prev.DateModified
    FROM    table1 curr
    LEFT
    JOIN    table1 prev
    on curr.file = prev.file
    and curr.scan_number = 100
    and prev.scan_number = 99
    WHERE   curr.DateModified != prev.DateModified
    OR      curr.file IS NULL
    OR      prev.file IS NULL
    

    If you want to catch inserts and deletes, you need full outer join, but it seems sqlite doesn’t support that. You might have to run the query twice, once to find inserts and updates, and once to find deletes.

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

Sidebar

Related Questions

So I need to track changes that happen on a Mysql table. I was
I have a situation where I need to keep track of all changes to
Need a function that takes a character as a parameter and returns true if
How could I track changes of specific directory in UNIX? For example, I launch
I have some code (which I cannot change) that I need to get working
I need to write an application in c# that keeps track of multiple tasks,
We are building a training website where we need to track viewers watching videos
I'm writing an Eclipse plugin for the JDT. I need a functionality that tracks
Need to an expression that returns only things with an I followed by either
We have a web application that is built on top of a SQL database.

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.