Re: Synching Multiple Tables
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Sun, 26 Aug 2007 07:59:21 -0400
<peter@xxxxxxxxxxxxxxxxxx> wrote in message
news:1188077501.100144.3070@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SELECT Field1, FIeld2, Field3
I have a database with 10 identical tables. What I would like to do is
pull all the data from all the tables into one master table. Reason is
that the data entered in the 10 tables is done online by different
users. Had to set it up like that because of user login permissions,
etc.
I would like to be able to produce a report showing the combined total
of the 10 tables. I'm getting more proficient with Access, but I'm
still a novice when it comes to SQL. I'm not even sure where to begin
with this. As of now, I manually go in and copy/paste the daily
numbers from each table into the master table.
Is there any way to update the master table any time the other 10
tables get updated? And will it happen automatically, or do I need to
manually synch them each night?
Do you really need a master table, or can you simply create a UNION query
that joins the ten tables together and use that UNION query instead?
Thanks for your response Doug. I'm sure that would work just fine. But
like I said, I'm not very proficient when it comes to SQL, which I
assume i would have to write to create a UNION query? Any tips on what
sort of code I would need?
FROM Table1
UNION
SELECT Field1, FIeld2, Field3
FROM Table2
UNION
....
UNION
SELECT Field1, FIeld2, Field3
FROM Table10
You have no choice but to work directly with the SQL, as you can't create
Union queries through the graphical query builder. What you can do, since
the 10 tables are identical, is create a query through the graphical query
builder for the first table, then go into the SQL View (under the View
menu), and copy-and-paste that first query 9 more times (remembering to put
UNION between each subquery)
Note that Union queries are not updatable (just in case that's an issue to
you). Also, note that UNION will eliminate duplicates. If you don't wish the
duplicate entries to be eliminated, use UNION ALL instead.
If you have a desire to know from which table a given entry comes, you can
use
SELECT Field1, FIeld2, Field3, "Table1" As DataSource
FROM Table1
UNION
SELECT Field1, FIeld2, Field3, "Table2" As DataSource
FROM Table2
UNION
....
UNION
SELECT Field1, FIeld2, Field3, "Table10" As DataSource
FROM Table10
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
.
- References:
- Synching Multiple Tables
- From: peter
- Re: Synching Multiple Tables
- From: Douglas J. Steele
- Re: Synching Multiple Tables
- From: peter
- Synching Multiple Tables
- Prev by Date: Re: Synching Multiple Tables
- Previous by thread: Re: Synching Multiple Tables
- Index(es):
Relevant Pages
|