Solved Combining Two Queries with Same Field (1 Viewer)

Weekleyba

Registered User.
Local time
Yesterday, 21:05
Joined
Oct 10, 2013
Messages
501
I have two queries A_Q and B_Q. (simplified the names)
Each gives a list of projects that will be funded, based on different funding limits for each and uses a Balance field where the criteria is >0, to show only the projects that can be funded.
Both queries have a unique ProjectID, but have been queried differently based on the funding type.

I want to combine these two queries to show all the projects to be funded. i.e. all the ProjectIDs, ProjectTitles, etc.

How can I do this?

1644347433317.png
 

oleronesoftwares

Passionate Learner
Local time
Yesterday, 19:05
Joined
Sep 22, 2014
Messages
1,138
Share the tables producing the queries and relationships.

Though the image you shared looks more like tables, not queries, is this the case?

If this is the case, then a select statement with inner join should work.
 

Weekleyba

Registered User.
Local time
Yesterday, 21:05
Joined
Oct 10, 2013
Messages
501
They are both queries but I think I may have figured it out.
I used a union query and it seems to give me what I want.
I really needed to get all the ProjectIDs in one query to use as input for a chart.
Does this seem like the correct use for a union query?

1644349228020.png
 

oleronesoftwares

Passionate Learner
Local time
Yesterday, 19:05
Joined
Sep 22, 2014
Messages
1,138
Union query- this will bring items from both queries(more results in columns are returned)
Inner join- This will bring like items from both queries.(fewer results in columns are returned)

If the union query you shared displays the result you want, then proceed to use it, but test it with varied data from both queries.
 

Gasman

Enthusiastic Amateur
Local time
Today, 03:05
Joined
Sep 21, 2011
Messages
10,544
I would go back to the source queries and use one of them with both the criteria used in each?
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 22:05
Joined
Feb 19, 2002
Messages
36,296
Either what Gasman said or the union query will work. Probably Gasman's suggestion is more efficient but sometimes we go with simplicity rather than efficiency. This isn't a hard "do it this way" because when Access creates the execution plan for the union, it incorporates the execution plans for the subordinate queries and may in fact run one query with multiple criteria itself.

There are situations, with left joins in particular, where you need to coerce Access into doing the right thing by actually breaking one query into two so you can force a specific order of execution.
 

Users who are viewing this thread

Top Bottom