Reputation: 131
I have two tables, say table1 with two rows of data say row11 and row12 and table2 with 3 rows of data sat row21, row22, row23
Can anyone provide me with the SQL to create a query that returns
row11
row12
row21
row22
row23
Note: I dont want to create a new table just return the data.
Upvotes: 13
Views: 92679
Reputation:
In MS Access you can achieve the same goal with an INSERT INTO query:
INSERT INTO TABLE1 SELECT * FROM TABLE2;
Upvotes: 1
Reputation: 332581
Use UNION ALL
, based on the example data:
SELECT * FROM TABLE1
UNION ALL
SELECT * FROM TABLE2
UNION
removes duplicates - if both tables each had a row whose values were "rowx, 1", the query will return one row, not two. This also makes UNION
slower than UNION ALL
, because UNION ALL
does not remove duplicates. Know your data, and use appropriately.
Upvotes: 35
Reputation: 2880
Why not use a UNION?
SELECT Col1,Col2,Col3 FROM TABLE1
UNION
SELECT Col1,Col2,Col3 FROM TABLE2
Are the columns on the two tables identical?
Upvotes: 1