Re: 30 tables I need the Same 5 fields from wach of them!!!

From: Brendan Reynolds (brenreyn)
Date: 01/06/05


Date: Thu, 6 Jan 2005 13:55:22 -0000

You need a union query ...

SELECT Field1, Field2 FROM FirstTable
UNION SELECT Field1, Field2 FROM SecondTable
etc., etc., etc.

If the table names are numbered, something like Table1, Table2, Table3 etc.,
it might be possible to write some code to build the SQL statement, and it
might be a little faster, or at least a little less tedious, than typing 30
SELECT statements.

Do you need me to tell you that this is not a good database design?

-- 
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com
The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
"Matt_Fairfield" <MattFairfield@discussions.microsoft.com> wrote in message 
news:A55F0E42-313A-40BA-A706-600445293004@microsoft.com...
>I have 30 different tables and i need to pull the date, time,ID, plus a
> couple other columns from each.
> Can i do it in one step??
> So i want to tell the query to go pick these 5 columns from all the
> different tables.
> Thanks Matt 


Relevant Pages

  • Re: Sum Fields which have blank records
    ... SELECT Record, Field1 as TheValue ... SELECT Record, Field2 ... You can then create a totals query from the union query that groups by ...
    (microsoft.public.access.reports)
  • Re: Joining tables
    ... Try a UNION query, i.e.: ... Field1 = David ... Field2 = Florida ...
    (comp.databases.ms-access)
  • Re: How to find Minimum of four fields
    ... SELECT Id, Field1, Field2, "PhoneCost" AS CostType, PhoneCost AS CostAmount ...
    (microsoft.public.access.gettingstarted)
  • Re: How to find Minimum of four fields
    ... Let's assume you currently have a table with Id, Field1, Field2, WebCost, ... PhoneCost, StoreCost, and ShowCost. ...
    (microsoft.public.access.gettingstarted)
  • RE: Querying by multiple dates
    ... UNION ALL SELECT Field1, Field2, Date2 AS VisitDate ...
    (microsoft.public.access.queries)