Chat with a LIVE Microsoft Access Expert!
 
       
 

         

   

Go Back   Access World Forums > Microsoft Access Discussion > Queries

 
 
Chat with a LIVE Microsoft Access Expert!
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-17-2006, 05:40 PM
danikuper's Avatar
danikuper danikuper is offline
Registered User
 
Join Date: Feb 2003
Location: Boston, MA
Posts: 147
danikuper
Consolidating multiple queries into one single result

I couldn't find a similar question already answered, so here it goes. I have multiple tables used to store information on different research materials:

table Books:
- BookID
- Author
- Title
- Year
- Cabinet

table Papers:
- PaperId
- Author
- Title
- Year
- Cabinet

table Catalog:
- CatalogID
- Author
- Title
- Year
- Cabinet

And I have a query for each of those tables that helps me find information. What I'm trying to do is to consolidate the result of those individual queries into one single query that later I can insert into a form to display a search result.

So the resulting query would look like:

Type.....ID....Author.....Title....Year....Cabinet
Book.....001...John.....Good book....2005....C01
Book....002.....Mary....Other book...2006...C01
Paper....001....Albert...PaperABC....1987....C01
Paper...002....John.....PaperXYZ.....2006....C02
Catalog...001...Mark....Cat00A....1989.....C02
Catalog...002...Bill......Cat00B.....2004.....C03
etc.

Is this possible?

Any help is appreciated!

Thanks.
Daniel
Reply With Quote
Sponsored Links
  #2  
Old 12-17-2006, 06:58 PM
john471's Avatar
john471 john471 is offline
Registered User
 
Join Date: Sep 2004
Location: And the winner is... Syd-a-knee
Posts: 392
john471 is on a distinguished road
The type of query you are looking for is termed a Union Query. MS Access help is reasonably good on this, once you know what to search for ("union query").

HTH

Regards

John.
__________________
And as I always like to say...
"Half a proverb is better than."
Reply With Quote
  #3  
Old 12-17-2006, 07:06 PM
john471's Avatar
john471 john471 is offline
Registered User
 
Join Date: Sep 2004
Location: And the winner is... Syd-a-knee
Posts: 392
john471 is on a distinguished road
Are the fields you listed the only fields in each of your tables, or are there others? If they are the only fields, then you should consider reading up on database normalisation. Even if they aren't, you should perhaps still read up on it. A better structure may be:-

tblResearchMaterialType
-------------------
ResearchMaterialTypeID (AutoNumber, PK)
ResearchMaterialType

tblResearchMaterial
-------------------
ResearchMaterialID (Autonumber, PK)
ResearchMaterialTypeID (FK to tblResearchMaterialType)
Author
Title
Year
Cabinet

From the details you posted above, your tblResearchMaterialType would have three records:-
1, Book
2, Paper
3, Catalog

You could add other fields in tblResearchMaterial, even if they are not used for every record, or every type of research material.

HTH

Regards

John.
__________________
And as I always like to say...
"Half a proverb is better than."
Reply With Quote
  #4  
Old 12-18-2006, 04:55 PM
danikuper's Avatar
danikuper danikuper is offline
Registered User
 
Join Date: Feb 2003
Location: Boston, MA
Posts: 147
danikuper
Thanks! I'll check the union queries help and see if I can figure out how to use it. As for your point with normalization, the tables do have some additional fields. In addition to that, I'd like to speed up queries since that's the purpose of the database 90% of the time and the user will usually want to search on 'catalogs' or 'books' only anyways.

Thanks for the help!
daniel
Reply With Quote
  #5  
Old 12-18-2006, 05:19 PM
john471's Avatar
john471 john471 is offline
Registered User
 
Join Date: Sep 2004
Location: And the winner is... Syd-a-knee
Posts: 392
john471 is on a distinguished road
Good luck with it. I still suggest you look into normalisation - it will save you headaches in the long run; and the sooner you do it the easier it will be. Add an index to the FK field, and I'm sure you'll find performance is acceptable.
__________________
And as I always like to say...
"Half a proverb is better than."
Reply With Quote
Sponsored Links
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Horizontal lines that grow with text kcolbert01 Reports 12 06-01-2009 10:01 AM
combine multiple records into a single mailmerge bluetongue Modules & VBA 1 03-08-2009 05:55 PM
Single Field into Multiple Fields Mike Hughes Queries 1 10-18-2004 08:51 AM
How to run multiple queries ChillSpill Queries 1 02-23-2004 03:30 PM
displaying numbers as words jhansen Reports 2 07-25-2001 07:34 AM


All times are GMT -8. The time now is 04:47 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
(c) copyright 2009 Access World