dbTalk Databases Forums  

Newbie query question

comp.database.ms-access comp.database.ms-access


Discuss Newbie query question in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mike Cooper
 
Posts: n/a

Default Newbie query question - 04-04-2004 , 11:23 PM






Hi,

I have a simple question. I have 5 different tables. I would like to
build a query that simple displays all of the data of all of the
tables without exception and without hitting a cartesian product. The
tables are all nearly identical with the exception of 1 or 2 columns.
Is this possible?

Reply With Quote
  #2  
Old   
Ray
 
Posts: n/a

Default Re: Newbie query question - 04-05-2004 , 08:09 AM






bidalah (AT) yahoo (DOT) com (Mike Cooper) wrote in message news:<df4443e2.0404042023.4cce3033 (AT) posting (DOT) google.com>...
Quote:
Hi,

I have a simple question. I have 5 different tables. I would like to
build a query that simple displays all of the data of all of the
tables without exception and without hitting a cartesian product. The
tables are all nearly identical with the exception of 1 or 2 columns.
Is this possible?
Hello Mike,

Access has a type of query called a "Union" query. This is what
would be needed to get all records from all of your tables.

Just one thing, make sure all fields in all tables are the same.
Example: tbl01 - Field01: LongInteger, Field02: Text, Field03: Text.
tbl02 - Field01: LongInteger, Field02: Text, Field03: Text, etc.

If not, then you can make a temporary query that souces each table
for the fields you want to source. I do something similar when
making Union queries. I make a query that sources my table with
the required fields, go into the SQL view and copy the text.

Then I paste it into another query I have already started which
is in SQL view already. I repeat for each table I need to source
so that I don't have to type any thing and make mistakes.

When I paste the second query's data, I add Union All before the
Select statement.

Example:

SELECT Table01.RecordID, Table01.Field01, Table01.Field02, Table01.Field03
FROM Table01;

Union All SELECT Table02.RecordID, Table02.Field01, Table02.Field02,
Table02.Field03 FROM Table02;

Union All SELECT Table03.RecordID, Table03.Field01, Table03.Field02,
Table03.Field03 FROM Table03;

Etc.

I don't like typing any more than I have to.

Regards,

Ray


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.