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
if you want to have the records of
donationtable displayed based on the latest donation date,