Select the most recent entry from multiple tables

chrisuff

New member
Local time
Today, 20:59
Joined
May 18, 2009
Messages
7
I have a query that selects records from four different tables.
The mother table contains personal information and three daughter tables are related to the first via the mother table's primary keywhich can have no entry per person, one entry per person or multiple entries per person.
A query that selects records form the mother table and information regarding them from the daughter tables. All entries have the date.
The user defines which criteria they want from the daughter tables from combo-boxes in a form which can be null (selects all records regardless of the criteria), a particular value, or "No record" which selects those with a null primary key.
Tis makes 27 different combinations all of which I have coded separately and it sort of works, except that I can not exclude records with multiple values appearing multiple times. I am already using SELECT DISTINCT
which removes duplicates only,
How can I select only the most recently added entry?
 
As always happens, I figure out how to do it about an hour after posting on this site..

Create queries for all 3 daughter tables.
First Query is to SELECT DISTINCT the reference to the mother table's primary key.
Second query joins the first query to the originating table and counts the number of events for each person in the table, then selects the last entry.

Put all these queries into the master query and refer to them instead of the daughter tables, making sure you impose similar joins to them, and it works! Simple - why didn't I work it out weeks ago...
 

Users who are viewing this thread

Back
Top Bottom