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 » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query from differnt tables



 
 
Thread Tools Display Modes
  #1  
Old June 30th, 2009, 09:22 PM posted to microsoft.public.access
LG
external usenet poster
 
Posts: 207
Default Query from differnt tables

I have tables 5 seperate tables with the same fields in all of them. I have
a seperate table with employees id and their name.
I need to set up a query for a report that will have the information to pull
into 1.
Ex. The report needs to show how many batch_id in each platform with their
name showing instead of their ID.
Fields : ID , Batch_ID, Platform
The employee table has ID and name.
Outcome would be ex: Smith 62 commerical, Smith 62 Medical than a total.
  #2  
Old June 30th, 2009, 09:43 PM posted to microsoft.public.access
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Query from differnt tables

5 seperate tables with the same fields in all of them.
You should have only one. Use a union query to pull them together --
SELECT ID , Batch_ID, Platform, "Tb1" AS [TBL]
FROM Table1
UNION ALL SELECT ID , Batch_ID, Platform, "Tb2" AS [TBL]
FROM Table
UNION ALL SELECT ID , Batch_ID, Platform, "Tb3" AS [TBL]
FROM Table3
UNION ALL SELECT ID , Batch_ID, Platform, "Tb4" AS [TBL]
FROM Table4
UNION ALL SELECT ID , Batch_ID, Platform, "Tb5" AS [TBL]
FROM Table5

The output field [TBL] above is if you really need to know where the data
came from.

Then use a totals query --
SELECT Name, Batch_ID, Count(Batch_ID) AS Batch_Total
FROM Employee LEFT JOIN MyUnionQuery ON Employee.ID = MyUnionQuery
GROUP BY Name, Batch_ID;

"LG" wrote:

I have tables 5 seperate tables with the same fields in all of them. I have
a seperate table with employees id and their name.
I need to set up a query for a report that will have the information to pull
into 1.
Ex. The report needs to show how many batch_id in each platform with their
name showing instead of their ID.
Fields : ID , Batch_ID, Platform
The employee table has ID and name.
Outcome would be ex: Smith 62 commerical, Smith 62 Medical than a total.

  #3  
Old June 30th, 2009, 09:59 PM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Query from differnt tables

On Tue, 30 Jun 2009 13:22:01 -0700, LG wrote:

I have tables 5 seperate tables with the same fields in all of them.


Then you have a misdesigned database. It would be much better to have ONE
table with an additional field identifying which batch of information this
record belongs to.

I have
a seperate table with employees id and their name.
I need to set up a query for a report that will have the information to pull
into 1.
Ex. The report needs to show how many batch_id in each platform with their
name showing instead of their ID.
Fields : ID , Batch_ID, Platform
The employee table has ID and name.
Outcome would be ex: Smith 62 commerical, Smith 62 Medical than a total.


You'll need to create a query with the employee table, and join *all five* of
the other tables to it by ID. Use a "Left Join" - select the join line in the
query window and select option 2 "Show all records in Employees and matching
records in other table".
--

John W. Vinson [MVP]
  #4  
Old July 7th, 2009, 05:43 PM posted to microsoft.public.access
LG
external usenet poster
 
Posts: 207
Default Query from differnt tables

How do I get it to have date parameters? Where the supervisor or processor
can pull up their completed work by date(s)
"KARL DEWEY" wrote:

5 seperate tables with the same fields in all of them.

You should have only one. Use a union query to pull them together --
SELECT ID , Batch_ID, Platform, "Tb1" AS [TBL]
FROM Table1
UNION ALL SELECT ID , Batch_ID, Platform, "Tb2" AS [TBL]
FROM Table
UNION ALL SELECT ID , Batch_ID, Platform, "Tb3" AS [TBL]
FROM Table3
UNION ALL SELECT ID , Batch_ID, Platform, "Tb4" AS [TBL]
FROM Table4
UNION ALL SELECT ID , Batch_ID, Platform, "Tb5" AS [TBL]
FROM Table5

The output field [TBL] above is if you really need to know where the data
came from.

Then use a totals query --
SELECT Name, Batch_ID, Count(Batch_ID) AS Batch_Total
FROM Employee LEFT JOIN MyUnionQuery ON Employee.ID = MyUnionQuery
GROUP BY Name, Batch_ID;

"LG" wrote:

I have tables 5 seperate tables with the same fields in all of them. I have
a seperate table with employees id and their name.
I need to set up a query for a report that will have the information to pull
into 1.
Ex. The report needs to show how many batch_id in each platform with their
name showing instead of their ID.
Fields : ID , Batch_ID, Platform
The employee table has ID and name.
Outcome would be ex: Smith 62 commerical, Smith 62 Medical than a total.

  #5  
Old July 7th, 2009, 06:53 PM posted to microsoft.public.access
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Query from differnt tables

Add you date field into the union and totals queries.

"LG" wrote:

How do I get it to have date parameters? Where the supervisor or processor
can pull up their completed work by date(s)
"KARL DEWEY" wrote:

5 seperate tables with the same fields in all of them.

You should have only one. Use a union query to pull them together --
SELECT ID , Batch_ID, Platform, "Tb1" AS [TBL]
FROM Table1
UNION ALL SELECT ID , Batch_ID, Platform, "Tb2" AS [TBL]
FROM Table
UNION ALL SELECT ID , Batch_ID, Platform, "Tb3" AS [TBL]
FROM Table3
UNION ALL SELECT ID , Batch_ID, Platform, "Tb4" AS [TBL]
FROM Table4
UNION ALL SELECT ID , Batch_ID, Platform, "Tb5" AS [TBL]
FROM Table5

The output field [TBL] above is if you really need to know where the data
came from.

Then use a totals query --
SELECT Name, Batch_ID, Count(Batch_ID) AS Batch_Total
FROM Employee LEFT JOIN MyUnionQuery ON Employee.ID = MyUnionQuery
GROUP BY Name, Batch_ID;

"LG" wrote:

I have tables 5 seperate tables with the same fields in all of them. I have
a seperate table with employees id and their name.
I need to set up a query for a report that will have the information to pull
into 1.
Ex. The report needs to show how many batch_id in each platform with their
name showing instead of their ID.
Fields : ID , Batch_ID, Platform
The employee table has ID and name.
Outcome would be ex: Smith 62 commerical, Smith 62 Medical than a total.

 




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 07:38 AM.


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