I have a query like this:
SELECT a.title,
a.spec,
a.name,
l.User AS CreatedBy,
DateAdd ( "s", l.time, #03/01/1980# ) AS CreatedAt
FROM
(Reports AS a
INNER JOIN
AuditLog AS l ON a.id = l.id)
INNER JOIN
(SELECT min([time]) AS Mintime,
id FROM AuditLog GROUP BY id)
AS t ON (l.time = t.mintime)
AND (l.id = t.id)
WHERE (((a.ACTIVE)='Y'));
The table Reports has 15000 records and AuditLog has 25800. But this query only returns 7800 results, and I figured there would be more (an audit is generated when a Report is created, so one would assume there’s a matching audit for every Report).
What are some new queries I could make to research what is missing, such as record counts etc? I did try copying this query and using OUTER JOIN, but it gave me “Syntax error in JOIN operation”. Most are active, so removing the WHERE clause is not the cause.
Here’s an example of using
Left Join.This will show all records in Reports, regardless of whether there are matches in the AuditLog table.
Here’s an extract from the database documenter feature of my test database:
I notice Access has added some more parentheses in. Also, the documenter missed the where clause for some reason. It’s in the query definition.