Append 2 files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 2 files each with the same fields that I'm just trying to append to
each other. For example:

File1
id age
1 10
2 20
3 30

File2
id age
4 40
5 50
6 60

And I want:
id age
1 10
2 20
3 30
4 40
5 50
6 60

Can I do this in SQL?
 
I have 2 files each with the same fields that I'm just trying to append to
each other. For example:

File1
id age
1 10
2 20
3 30

File2
id age
4 40
5 50
6 60

And I want:
id age
1 10
2 20
3 30
4 40
5 50
6 60

Can I do this in SQL?

two files or two tables?
You can use a union query

SELECT id, age
FROM table1
UNION ALL
SELECT id, age
FROM table2
ORDER BY id, age;

if the field names do not match, you need to alias them

SELECT idno AS id, age
FROM table1
WHERE...
UNION ALL
SELECT id, age
FROM table2
ORDER BY id, age;
 
David,

If you want to actually append the data from one table into the other,
use an Append query. This is easy to do from the Query screen. The SQL
would look something like:

Insert Into Table1 (id, age) Select id, age from Table 2

If id is an AutoNumber field, then don't include it in the query.

Jerry
 
David said:
I have 2 files each with the same fields that I'm just trying to append to
each other. For example:

File1
id age

If you have an age field it needs to be constantly updated. It's better
to obtain the birthdate, enter it once, then calculate age as needed.
Look up "birthday" in this NG for various calculation methods.

James A. Fortune
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top