A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Help on muliple table queries



 
 
Thread Tools Display Modes
  #1  
Old May 28th, 2010, 11:43 AM posted to microsoft.public.access.queries
Natalie
external usenet poster
 
Posts: 212
Default Help on muliple table queries

Hi all,
I wonder if you can help. I have 5 tables of data with the same column names.
I want to run a query which includes all records from all tables within a
certain time period using a from/to date.

Is this possible/simple, and how do I do it!!
Thanks
Natalie
  #2  
Old May 28th, 2010, 02:31 PM posted to microsoft.public.access.queries
Wolfgang Kais[_4_]
external usenet poster
 
Posts: 18
Default Help on muliple table queries

Hello Natalie.

"Natalie" wrote:
Hi all,
I wonder if you can help. I have 5 tables of data with the same
column names. I want to run a query which includes all records from
all tables within a certain time period using a from/to date.

Is this possible/simple, and how do I do it!!


Supposed that your tables were named MyTable1, ... MyTable5 and the
date/time column was named DateCol, you could do the following:
Create a new blank query. Close the add table window without adding
any table. Switch to the SQL view of the query and enter something
like the following:

PARAMETERS [From Date] DateTime, [To Date] DateTime;
SELECT * FROM MyTable1 WHERE DateCol BETWEEN [From Date] AND [To Date]
UNION ALL
SELECT * FROM MyTable2 WHERE DateCol BETWEEN [From Date] AND [To Date]
UNION ALL
SELECT * FROM MyTable3 WHERE DateCol BETWEEN [From Date] AND [To Date]
UNION ALL
SELECT * FROM MyTable4 WHERE DateCol BETWEEN [From Date] AND [To Date]
UNION ALL
SELECT * FROM MyTable5 WHERE DateCol BETWEEN [From Date] AND [To Date];

--
Regards,
Wolfgang


 




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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:17 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.