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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:11:38+00:00 2026-05-16T16:11:38+00:00

I have a logfile which logs the insert/delete/updates from all kinds of tables. I

  • 0

I have a logfile which logs the insert/delete/updates from all kinds of tables.
I would like to get an overview of for example the last 20 people which records where updated, ordered by the last update datetime DESC

What I have now is:

SELECT DISTINCT logfile.idvalue, DATE_FORMAT(logfile.logDateTime,'%d-%m-%Y  %H:%i') AS thedatetime, CONCAT_WS(' ',people.peopleSurname,people.peopleLastname) AS peopleName
FROM logfile,people
WHERE 0=0
AND logfile.tablename='people'
AND logfile.action='update'
AND logfile.idvalue=people.peopleID
GROUP BY logfile.idvalue
ORDER BY logfile.logDateTime DESC,logfile.idvalue DESC

But this results in logDateTimes which don’t correspond to the datetime of the latest (Max) “update-entry”
What am i missing?!

thanks
Bart

  • 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-16T16:11:39+00:00Added an answer on May 16, 2026 at 4:11 pm
    SELECT  *
    FROM    logfile lf
    WHERE   tablename = 'people'
            AND action = 'update'
            AND logdatetime = 
            (
            SELECT  MAX(logdatetime)
            FROM    logfile lfi
            WHERE   lfi.idvalue = lf.idvalue
                    AND lfi.tablename = lf.tablename
                    AND lfi.action = lf.action
            )
    ORDER BY
            logdatetime DESC
    LIMIT 20
    

    Create the following indexes:

    (tablename, action, idvalue, logdatetime)
    (tablename, action, logdatetime)
    

    for this to work fast.

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

Sidebar

Related Questions

I have a logging script which saves to file logs. I would like to
I have a table which logs record counts of all tables in a schema
I have a formatted string from a log file, which looks like: >>> a=test
I have a PHPUnit Test which validates the output of a logfile with a
I have created a small program which logs text data to a file on
I have a batch file where I would like to append to the same
I'm using byobu /screen, and I would like to have a new screen session
I have a Python/Flask webapp with MongoDB database on DotCloud hosting. I would like
I have a log file which have logs very similar to Apache logs Here
I have one exe say myApp.exe in C:\MyProject folder. It writes logs in logfile

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.