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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:35:23+00:00 2026-06-05T21:35:23+00:00

I am currently making a program that will send an email if the date

  • 0

I am currently making a program that will send an email if the date of a persons last entry was over (some time frame). my table is laid out like this:

employee   | dept. | date       | other | 
bob        | 1     | 2012-05-29 | abc   |
bob        | 1     | 2012-07-15 | xyz   |
jon        | 2     | 2012-05-29 | abc   |

(i have sorted with mysql by employee then date)
so for example, for bob i want to automatically assign a variable to the date 2012-07-15 because that is the date of his last entry. then based on the current date i want to send an email if that time in between submissions has been to long. My question is how to i assign a variable to the last date of each person in the table? I am also open to different better ways of doing this. Thank you.

  • 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-05T21:35:26+00:00Added an answer on June 5, 2026 at 9:35 pm

    To return the latest date for each employee, something like this will work.

    SELECT employee
         , MAX(`date`) AS latest_date
      FROM mytable
     GROUP BY employee
     ORDER BY employee
    

    Addendum,

    As simbabque points out, this works for getting the latest date, but does not return the other value. There are a couple of approaches to getting that result set.

    If we are guaranteed that the (employee,date) is UNIQUE (for example. by a unique constraint), we can return other columns on the row that has the latest date with a query like this:

    SELECT t.employee, t.`date`, t.other
     FROM mytable t
     JOIN ( SELECT r.employee, MAX(r.`date`) AS latest_date
             FROM mytable r
            GROUP BY r.employee
          ) s
       ON s.employee = t.employee
      AND s.latest_date = t.`date`
    ORDER BY t.employee
    

    If we aren’t guaranteed that (employee, date) is unique, this query would not suffice. But there are a couple of approaches to addressing that issue.

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

Sidebar

Related Questions

I'm currently making some system that will gather statistical reports from different sites, for
I am currently making some Acceptance-Tests that will help drive the design of a
I'm currently making a PHP-program that solves equations. I've divided the input equation into
I'm currently making a basic maths application in Android. Program will print on std
I'm making a program that will output lines to a text file. I don't
Here is my code currently. I'm making a java program that seaches Active Directory
I'm currently making a whimsical iPhone app that will allow you to change your
I'm currently making a program that saves Chinese Words onto a text file. I
I'm currently making a GWT project where I display some HTML in a RichTextArea
I'm currently making an iPhone app that has PDF viewing a crucial part of

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.