Joining results of two queries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having trouble joining the results of two different queries. I know that
I could make both of them make table queries and then run a query to bring
the four columns I'm interested in bringing together into one query result,
but was hoping that there might be a way to bring two columns from each
together in one output, which I could subsequently put into a report. Both
queries share two common fields and then have two unique fields. Any
suggestions? Thanks in advance
 
Not sure if that what you are trying to do, if you want to list in one query
the resault of two other queries, you can use a Union Query to join them

Select Field1, Field2 From Query1Name
Union
Select Field1, Field2 From Query2Name
 
Hi Ofer,

OK, here is the SQL syntax of the queries:

SELECT tblCOMU_firstegg_made_from_union.[Sub-colony],
tblCOMU_firstegg_made_from_union.[Site number],
Min(tblCOMU_firstegg_made_from_union.[Egg first seen]) AS [Egg first seen],
Min(tblCOMU_firstegg_made_from_union.[Expected Hatch Date]) AS [Expected
Hatch Date]
FROM tblCOMU_firstegg_made_from_union
GROUP BY tblCOMU_firstegg_made_from_union.[Sub-colony],
tblCOMU_firstegg_made_from_union.[Site number];

UNION

SELECT tblCOMU_Chick_first_seen_union.[Sub-colony],
tblCOMU_Chick_first_seen_union.[Site number],
Min(tblCOMU_Chick_first_seen_union.[Chick first seen]) AS [Chick first seen],
Min(tblCOMU_Chick_first_seen_union.[Expected fledge date]) AS [Expected
fledge date]
FROM tblCOMU_Chick_first_seen_union
GROUP BY tblCOMU_Chick_first_seen_union.[Sub-colony],
tblCOMU_Chick_first_seen_union.[Site number];

When I run this, the two queries lump my chick first seen and expected
fledge date into the egg first seen and expected hatch date. What I would
like is essentially to have a result have the field sub-colony, site number,
egg first seen, expected hatch, chick first seen, expected fledge. (i.e.
append the last two fields to the first query, keeping them associated with
the same site number).
 
Hey Ofer,

I finally figured it out. I changed some other steps leading up to the
Union step, which meant I could just run a query with a relationship between
two fields and bring the four unique fields into one result! This way I
don't have to even run a Union query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top