Solved

How To Combine Tables in Access

Posted on 2004-08-02
9
8,656 Views
Last Modified: 2011-08-18
Hi.....could you please tell me step by step how to combine tables with the excat same fields in Access. I read somehting aboutn a UNION query but have no idea how to do it. Thanks.
0
Comment
Question by:Nomad2012
9 Comments
 
LVL 17

Expert Comment

by:walterecook
ID: 11698969
Select field1, field2, field3
from table1
Union
select field1, field2, field3
from table2

This will throw out duplicates
If you want to include duplicates...
Select field1, field2, field3
from table1
Union
select ALL field1, field2, field3
from table2

The key is the number of fields must be the same and in the same order and each field must be of the same datatype.

Walt
0
 
LVL 11

Expert Comment

by:SweatCoder
ID: 11698973
select * from mytable1
union
select * from mytable2

if field number and types are not identical, you can't use *, you need field list and they must match up, both number and data type.
0
 
LVL 17

Accepted Solution

by:
walterecook earned 500 total points
ID: 11698974
Whoops
I moved the all....
rather,
Select field1, field2, field3
from table1
Union ALL
select field1, field2, field3
from table2


sorry
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 11

Expert Comment

by:SweatCoder
ID: 11698976
i guess i got beat to the punch.  :-)
0
 
LVL 44

Expert Comment

by:GRayL
ID: 11698989
In union queries, the first select statement provides the field names for the query. Thus a query Query1:

Select fld1, fd2, fld3 from table1
order by fld1
UNION
select fld43, fld22, fld33 from table2
order by fld43;

provides a table called Query1 in which each of the data types in each field of table1 are the same in each of the successive tables;
0
 
LVL 13

Expert Comment

by:TommyTupa
ID: 11699921
Union queries are OK but you can do the same thing with no coding given tables with exact structures.

1. Select table, right click and copy.
2. Rightclick Paste.
3. Select Paste Append and select the table to append to.
4. Click OK and you've just combined tables.
0
 
LVL 17

Expert Comment

by:walterecook
ID: 11703746
Well Tommy, that's true.  But an Append query works much better for something like that.

Walt
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now