Combine 2 queries from 2 different databases

C

Chey

I am working with a database that someone else created from a consulting
company. Prior to my time, people were using one database, and another one
with just a slight name difference. I need to combine the two queries with
out the dups. However when I just simply take the one query and copy and
paste it into the query I want, it will not paste. There are no table for me
to just update info in? I am not sure what to do.

Can someone please guide me?
 
P

pietlinden

I am working with a database that someone else created from a consulting
company. Prior to my time, people were using one database, and another one
with just a slight name difference. I need to combine the two queries with
out the dups. However when I just simply take the one query and copy and
paste it into the query I want, it will not paste. There are no table forme
to just update info in? I am not sure what to do.

Can someone please guide me?

If your final goal is editing a list of the two combined datasets
(from the two queries), you will have to append one table's records to
the other. If you only want to see/use the data (no adds/edits/
deletes), you can use a union query. A regular union will remove the
duplicates for you, and using UNION ALL will return all records,
duplicate or not. to make it work, your two data sets have to have
the same type columns (but not the same name). The easiest way to
build one is to open up one of the queries, copy and paste the SQL
into notepad, so you get something like this:

SELECT FirstName, LastName, MI
FROM Table1_in_Db1
WHERE ...;

then you slap a union statement on the next line (after removing the
final semi-colon)

UNION

and then you copy and paste the second query's SQL at the end.

SELECT FName, LName, Null As MI
FROM Table2_in_Db2
WHERE ...;

your resultset will return unique values and look like this...
FirstName, LastName, MI

but it will NOT be editable.

so the final statement will look like this:

SELECT FirstName, LastName, MI
FROM Table1_in_Db1
WHERE ...
UNION [ALL]
SELECT FName, LName, Null As MI
FROM Table2_in_Db2 IN 'C:\SomeFolder\NameOfDB.mdb'
WHERE ...;
 
N

ntc

also; one can not copy/paste a query like one can with text or docs....you
must begin in the destination DB and go to 'file' then 'Get External Data'
and then 'Import'
 
C

Chey

That is one of my problems. When I go to do that. The query is not under
query. I am not sure where it is housed? There are only 2 queries in this
database. I found the other one. I wanted to just paste the information into
a table, but there are no tables either. Any other suggestions for me?

Thanks
 

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

Top