How do I avoid the union query sucking up the individuality of my tables (1 Viewer)

CarlaKingery

New member
Local time
Today, 20:09
Joined
May 30, 2002
Messages
8
Oh help, I just need one piece and my database would be perfect...well almost.

I created a union query with the following syntax:

SELECT [Parent Company Name], [IOU], [Count], [SumOfCount]
FROM [Utilparentcount]

UNION ALL SELECT [Parent Company Name], [NonIOU], [Count], [SumOfCount]
FROM [UtilparcountNonIOU]

UNION ALL SELECT [Parent Company Name], [LDC], [Count], [SumOfCount]
FROM [UtilparcountLDC]

It worked beutifully, except I need to have a separate field that shows from what table each record originated. This is important because it tells me what type of utility each record is IOU, NonIOU, or LDC. Any suggestions?

C
 

llkhoutx

Registered User.
Local time
Today, 14:09
Joined
Feb 26, 2001
Messages
4,018
SELECT [Parent Company Name], [IOU], [Count], [SumOfCount], "Table A" AS Source
FROM [Utilparentcount]

UNION ALL SELECT [Parent Company Name], [NonIOU], [Count], [SumOfCount], "Table B" AS Source
FROM [UtilparcountNonIOU]

UNION ALL SELECT [Parent Company Name], [LDC], [Count], [SumOfCount], "Table C" AS Source
FROM [UtilparcountLDC]
 

CarlaKingery

New member
Local time
Today, 20:09
Joined
May 30, 2002
Messages
8
Thanks so much, Perfect!!

C
 

KKilfoil

Registered User.
Local time
Today, 15:09
Joined
Jul 19, 2001
Messages
336
*** Normalization Alert! ****

Why have 3 different tables?

You should add a 'UtilityType' Field and store all data in one table. Then your queries and everything else gets much simpler.

Look up 'normalization' in this forum's search feature or Access help for more information on how and why your database should be normalized!
 

Users who are viewing this thread

Top Bottom