tags:

views:

37

answers:

3

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.

Tahnks

+3  A: 
select * from table1 union select * from table2
Ned Batchelder
Thanks - much appreciated
Dave
A: 

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?

Myles J
A: 

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.

OMG Ponies