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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:13:20+00:00 2026-06-17T12:13:20+00:00

I use a MySQL database to manage donations for an organisation. Donators can make

  • 0

I use a MySQL database to manage donations for an organisation. Donators can make more than one donations. Thus I have two tables: donators contains information about the donators and donations contains information about time and amount of the donations. Both tables are connected via a donatorID.

I want to read out information about each distinct donator. The list should be ordered by the date of the last donation. I came up with the code below, but that uses the date of the first donation instead of the last donation.

How can I use the newest donation-date for each donator?

SELECT
    DISTINCT(`donators`.`name`),
    `donators`.`city`,
    `donators`.`country`,
    `donators`.`website`
FROM
    `donators`
INNER JOIN
    `donations`
ON
    `donators`.`donatorID` = `donations`.`donatorID`
ORDER BY `donations`.`date` DESC
  • 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-17T12:13:22+00:00Added an answer on June 17, 2026 at 12:13 pm
    SELECT  a.*, b.max_DATE
    FROM    Donators a
            INNER JOIN
            (
                SELECT  DonatorID, MAX(date) max_DATE
                FROM    Donations
                GROUP   BY DonatorID
            ) b ON a.DonatorID = b.DonatorID
    ORDER   BY  b.max_DATE DESC 
    

    if you want to have the records of donation table displayed based on the latest donation date,

    SELECT  a.*, c.*
    FROM    Donators a
            INNER JOIN Donations c
                ON a.DonatorID = c.DonatorID
            INNER JOIN
            (
                SELECT  DonatorID, MAX(date) max_DATE
                FROM    Donations
                GROUP   BY DonatorID
            ) b ON  c.DonatorID = b.DonatorID AND
                    c.date = b.max_DATE
    ORDER   BY c.date DESC  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a registration program. Making use of mysql database. Can I still
I have a MySQL database and I use a while loop to take information
I currently have a MySQL database which I was hoping to use to store
I have a Symfony application which use a mysql database to store session data,
I use PHP and MySQL to manage the content on my server/site (I have
I have A MySQL database currently in production use for a CakePHP application A
Database is MySQL. I use the django.contrib.auth. Here is all the info: manage.py dumpdata
I'm trying to use a MySQL database to save player information, but whenever there
I use SS.Users stored in mysql database. Database and Column charset is UTF-8 When
I created a new mysql database and i want to use foreign keys with

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.