We have a project database in MSACCESS with the following tables:
table PROJECTS with of course an ID and project details.
table COMMENTS with an ID, a DATE and a comment text field.
COMMENTS is linked to PROJECTS with a one-many relation. (a project can have multiple comments)
What I want is a query that selects all projects with at least one comment with a date that is less than 3 months old.
I tried an inner join and got the filter right, but I thought that with the distinctrow or distinct I could filter out the doubles, but msaccess won’t accept the syntax.
It’s a simple task that in any programming environment would be easy to do, but I just can’t get it into a single query…
[update]:
I have one little additional question: Only the records with at least one comment show up and we want new projects (with no comments yet) to show up too. I tried adding an
"OR count(SELECT projectid FROM comments WHERE (( ( comments.commentdate ) BETWEEN Dateadd("m", -3, DATE()) AND DATE()))) =0
Since you seems to want distinct Projects but not the associated comment data there are several of ways to accomplish this.
LEFT Join Distinct
LEFT Join With Group by
IN Clause
Exists Clause
INNER JOIN to an INLINE View With a UNION to a LEFT JOIN