Help with joining 2 queries

R

Robert Raley

I have 2 queries that queries the same tables but are retrieving different
data

query 1 has the following fields
period_start
period_end (this is the criteria field say for example #10/30/2004#)
mod_stats_id
stage_name
shifts_worked

query 2 has the following fields.
period_start
period_end (this is the criteria field say for example #9/30/2004#)
stage_name
minutes
conversion.

I need to combine both queries into one where all stage names are listed.
Query one will have some name that are not listed in query 2. The same
applies to query 2, it will have some name that are not list in query 1.
Both queries will have some names in common.

In the end I need to produce a report based on stage_name using the data
from both queries.

Help please I am going nuts.

Thanks

Bob
 
J

John Vinson

I need to combine both queries into one where all stage names are listed.
Query one will have some name that are not listed in query 2. The same
applies to query 2, it will have some name that are not list in query 1.
Both queries will have some names in common.

In the end I need to produce a report based on stage_name using the data
from both queries.

A UNION query is the ticket here: you need to go into the SQL window
to do it, the grid can't handle it.

SELECT period_start, period_end, mod_stats_id, stage_name,
shifts_worked FROM Query1
UNION
SELECT period_start, period_end, mod_stats_id, stage_name,
shifts_worked FROM Query2;


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
R

Robert Raley

Thanks for the help. The problem is that I have not all columns are equal
in the queries. While query 1 returns certain data query 2 returns other
data. Some columes are the same some are different. I seem to be getting
error messages that there are not the same number of columns

Advise is welcome :)

Regards

Bob
 
J

John Vinson

Thanks for the help. The problem is that I have not all columns are equal
in the queries. While query 1 returns certain data query 2 returns other
data. Some columes are the same some are different. I seem to be getting
error messages that there are not the same number of columns

Advise is welcome :)

You may need to add "dummy" columns to the query with fewer fields;
and the order and datatypes of the fields must match, if you want to
do a UNION.

I guess I'm not clear what result you want. Do you want a searchable
Query? If there is a field [Shifts_Worked] in one query and not in the
other, what do you want to see in the query? If you just want a Report
showing both sets of data, consider a Report with two Subreports, one
bound to each query!

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 

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

Top