Union Query Help

SteveGr

Registered User.
Local time
Today, 07:55
Joined
Aug 2, 2002
Messages
65
I have two tables that have related fields in them. I would like to query these two tables to get all the data that the fields are the same.
If you look at the attached file, I would like to enter criteria for fields one,two and three from both tables, and have fields four five and six come back with data as well.
 

Attachments

  • sample.jpg
    sample.jpg
    20.2 KB · Views: 175
So what is the problem?
That you cannot create a union-query or fields4,5,6 or?
 
reply

I need to retrieve the records from fields four,five and six as well as the other fields. This is about retrieving records that are already in my 2 tables that have field headings.
 
Add the two tables to the QBE grid and draw three join lines. One to connect each pair of matching fields.
 
Im sorry, I feel so stupid. What is a QBE grid?
 
The QBE grid is the grid in the Design View of a query where there are cells for you to enter the fields, sort order, criteria etc. You can switch among the three views of a query using the View menu or the View button which is usually the first button on the tool bar.

Your Sample.jpg showed two tables each with four records. Do you want to have a query that pulls the records from both tables so that you have a query result of eight records? If you do, then the following union query will do (switch to the SQL View of a new query and type):-

SELECT * FROM Red
UNION SELECT *,0,0,0 FROM Blue;


Run the query.
 
Last edited:
I used a SQL statement "SELECT *" to query all fields from both tables, but the records under field headings got mixed up. This is probably due to the field headings are in a different order in the tables. But my table is layed out that way because I importing data from an excel spreadsheets that is being fed from different comma delimited sources. And I can't change the fields order.
How do I retrieve the correct records that match the field headings from both tables?
Thanks, Steve
 

Users who are viewing this thread

Back
Top Bottom