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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:27:05+00:00 2026-05-28T01:27:05+00:00

I am not sure why this behaves this way. I need to select few

  • 0

I am not sure why this behaves this way. I need to select few values from two tables based on some criteria which should be clear from the query i tried below.

query = @"SELECT n.borrower, a.sum, n.lender FROM Notification AS n, Acknowledgment AS a 
          WHERE n.deleted=@del2 AND n.id IN (SELECT parent_id FROM Acknowledgment
                                             WHERE status=@status AND deleted=@del1)";

This returns more rows (12) than expected.

I have two tables Notification and Acknowledgment both which have field “sum”. When I try the query below it gives the correct 3 rows as expected.

@"SELECT n.borrower, n.sum, n.lender FROM Notification AS n 
  WHERE n.deleted=@del2 AND n.id IN (SELECT parent_id FROM Acknowledgment
                                     WHERE status=@status AND deleted=@del1)";

Now I need to extend this query so that I need a.sum and not n.sum. But when I try the first query, it gives a lot more rows, I mean the WHERE condition doesn’t work. I dunno if its a quirk with MS Access or something wrong with query. I appreciate an alternate implementation in access if my query seems fine ‘cos it simply doesn’t work! 🙂

I have read here that different databases implement select in different ways. Dunno if its something specific with access..

After suggestion from Li0liQ, I tried this:

@"SELECT n.borrower, a.sum, n.lender FROM Notification AS n 
  INNER JOIN Acknowledgment AS a ON a.parent_id = n.id AND a.status=@status AND a.deleted=@deleted1 
  WHERE n.deleted=@deleted2"

But I now get a “JOIN expression not supported” error.

  • 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-28T01:27:06+00:00Added an answer on May 28, 2026 at 1:27 am

    This is expected behavior because of the cartesian product:

    FROM Notification AS n, Acknowledgment AS a
    

    If you have 10 notifications and 5 acknowledgements, you’ll get 50 rows in the result, representing all possible combinations of a notification and an acknowledgement. That set is then filtered by the WHERE clause. (That’s standard for SQL, not specific to MS Access.)

    It sounds like you need a JOIN:

    FROM Notification AS n INNER JOIN Acknowledgement AS a ON n.id = a.parent_id
    

    You can then get rid of the subquery:

    WHERE n.deleted=@del2 AND a.status=@status AND a.deleted=@del1
    

    EDIT

    As requested by nawfal, here is the solution he arrived at, which essentially incorporates the above recommendations:

    string query = @"SELECT n.borrower, a.sum, n.lender FROM Notification AS n   
               INNER JOIN Acknowledgment AS a ON a.parent_id=n.id   
               WHERE a.status=@status AND a.deleted=@deleted1 AND n.deleted=@deleted2"; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm still not sure this is the correct way to go about this, maybe
First of all I'm not sure this is even possible, however I need to
Context I'm trying to have some "plugins" (I'm not sure this is the correct
The Original Question I realized I am not 100% sure why this behaves the
Not sure this is possible, but looking to write a script that would return
I'm not sure this is possible, but in ruby, you can dynamically call a
I'm not sure this is possible, but is there a syntax to be used
I'm not sure this question is appropriate here but I hope I could get
I'm sure this is a fairly trivial problem, but I'm not sure what to
Ok I'm working on getting better with python, so I'm not sure this is

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.