Inserting Two Identical Tables Into One Table

lhooker

Registered User.
Local time
Today, 15:41
Joined
Dec 30, 2005
Messages
423
How can I insert the below "Select" queries results (that works) in to one (1) table.

SELECT Leadership.Name, Leadership.Survey_Taker_Telephone_Number, Leadership.Type, Leadership.Type_Score, Leadership.Contact_Me
FROM Leadership
Union
SELECT Administration.Name, Administration.Survey_Taker_Telephone_Number, Administration.Type, Administration.Type_Score, Administration.Contact_Me
FROM Administration;
 
You should be able to use that as the base of an append query.
 
the query should look like this:

INSERT INTO anotherTable (
[Name],
[Survey_Taker_Telephone_Number],
[Type], [Type_Score], [Contact_Me] )
FROM
(
SELECT
Leadership.Name,
Leadership.Survey_Taker_Telephone_Number,
Leadership.Type,
Leadership.Type_Score,
Leadership.Contact_Me
FROM Leadership
UNION ALL
SELECT
Administration.Name,
Administration.Survey_Taker_Telephone_Number,
Administration.Type,
Administration.Type_Score,
Administration.Contact_Me
)
 
The adage about feeding a man for a day vice for his life.
 
Nothing to be concerned about, truly. Did you try Arnelgp’s code? I am no expert, but it looks like it will work and he is usually right!
 
Arnelgp,

Did not work, I added 'From Administration', but it did fix the problem.

INSERT INTO anotherTable ( [Name], [Survey_Taker_Telephone_Number], [Type], [Type_Score], [Contact_Me] )
(SELECT Leadership.Name, Leadership.Survey_Taker_Telephone_Number, Leadership.Type, Leadership.Type_Score, Leadership.Contact_Me
FROM Leadership
UNION ALL
SELECT Administration.Name, Administration.Survey_Taker_Telephone_Number, Administration.Type, Administration.Type_Score, Administration.Contact_Me
FROM Administration
 
Arnelgp,

I did changed 'anotherTable' to another table name.
 
pbaldy,,

OK, got it . . . I have my fishing rod. Any takers ?
 
Did not work, I added 'From Administration', but it did fix the problem.
It would be helpful to us if you told us what problem you are experiencing. Are you getting an error message? Invalid results? What is invalid about the results? Please post your code.

PS - it is rarely necessary to create temp tables. You can simply use the union query as the recordsource for a form or report or export as needed. Of course a union is not updatable so they are rarely used as the RecordSource for forms.
 
Pat Hartman/jdraw,

Sorry for not responding ! ! ! I've off the forum for a few days. I ended up creating multiple queries and using a macro to call the queries. Thanks for following up ! ! !
 

Users who are viewing this thread

Back
Top Bottom