merge two tables in one queie

G

Guest

Hello.

I need to merge the results of two similar/equal tables. The
00_tbl_Badge_Actual table has the currenter recordset/register and the
01_tbl_Badge_Historico has the history registers.

What I need is to build in chronological order the registers. The column
with the date is MicroDate and the Employee number is EmployeeNumber

What I need it something like this:

For employee number 10

EmployeeNumber Microdate
10 01-02-2003
10 02-02-2003

Could you please help?

Regards in advanced,
Marco Silva
 
G

Guest

Marco,

You can build a UNION query. Start out by creating a new query, select one
of the two tables, and select all of the fields you want, in the order you
want them.

Then click on View -> SQL View.

Delete the ";" from the end of the query. Additionally, I usually go
through the query and remove references of the table name so that what looked
like:

SELECT Table1.Field1, Table1.Field2, Table1.Field3
FROM Table1

Now looks like:

SELECT Field1, Field2, Field3 from Table1

At this point, copy this text. Then on the next row type UNION ALL and on
the row below that, paste the text you previously copied. Once you have done
this, change the reference to Table1 (in the text you just pasted) to Table2,
so that the query looks like:

SELECT Field1, Field2, Field3 from Table1
UNION ALL
SELECT Field1, Field2, Field3 from Table2

The critical piece of information here is that the datatypes of the fields
must be the same in the two halves of this query.

Good Luck.

Dale
 
G

Guest

Hi Dale,

It's returning me 3 columns.

employee number Data Data1



I needed just two columns, why Data 1 appears?

Regards,
Marco
 
J

joebogey

Dale,

Thank you for the clear instructions. I was racking my brain and this solved
it 1-2-3.

Joe
 

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

Similar Threads


Top