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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:02:16+00:00 2026-05-25T06:02:16+00:00

We have a project database in MSACCESS with the following tables: table PROJECTS with

  • 0

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 
  • 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-05-25T06:02:17+00:00Added an answer on May 25, 2026 at 6:02 am

    Since you seems to want distinct Projects but not the associated comment data there are several of ways to accomplish this.

    LEFT Join Distinct

    SELECT DISTINCT projects.* 
    FROM   projects 
           LEFT JOIN comments 
             ON projects.id = comments.projectid 
    WHERE  (( ( comments.commentdate ) BETWEEN Dateadd("m", -3, DATE()) AND DATE() ) 
           ) or comments.projectid is null
    

    LEFT Join With Group by

    SELECT projects.id, 
       projects.fielda,
       [....]
    FROM   projects 
           LEFT JOIN comments 
             ON projects.id = comments.projectid 
    WHERE  (( ( comments.commentdate ) BETWEEN Dateadd("m", -3, DATE()) AND DATE() ) 
           ) or comments.projectid is null
    GROUP BY 
       projects.id, 
       projects.fielda,
       [....]
    

    IN Clause

    SELECT *
    FROM   projects 
    WHERE  id IN (SELECT projectid
              FROM   comments 
              WHERE  (( ( comments.commentdate ) BETWEEN 
                        Dateadd("m", -3, DATE()) AND DATE() 
                      ))) 
    

    Exists Clause

    SELECT * 
    FROM   projects 
    WHERE  EXISTS (SELECT * 
                   FROM   comments 
                   WHERE  ( comments.commentdate ) BETWEEN 
                          Dateadd("m", -3, DATE()) AND DATE() 
                          AND ( projects.id = comments.projectid )) 
         OR NOT EXISTS (SELECT * 
                   FROM comments
                   WHERE projects.id = comments.projectid)
    

    INNER JOIN to an INLINE View With a UNION to a LEFT JOIN

    SELECT *
    FROM   projects 
    INNER JOIN  (SELECT DISTINCT projectid
              FROM   comments 
              WHERE  (( ( comments.commentdate ) BETWEEN 
                        Dateadd("m", -3, DATE()) AND DATE() 
                      ))) comment
         ON projects.id = comment.projectid
    UNION ALL 
    SELECT * 
    FROM projects 
         LEFT JOIN comments
         ON projects.id = comment.projectid 
    WHERE  
         comment.projectid is null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project here that connects to an in-production database and grabs tables
I Have a DataBase in my project With Table named 'ProcessData' and columns named
I have data in an MYSQL database that looks like this: Project Date Time
I have database project in visual studio 2010. It has tables views stored procedures
we have database with some table-valued functions writen in C#. I have database project
I've got three database projects. I'd like to have the base project contain common
I have a database project (.dbp) open in Visual Studio 2008 as part of
In our team we have a database project in visual Studio 2008 which is
Do you have one solution with the web application project, class libraries, database project
I have a database solution project in VS2008 - it generates SQL for more

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.