There is a table1 with records (1,2,3,4,5,6) and table2
with records (4,5,6,7,8,9).write a query so as to get the
result as 1,2,3,4,5,6,7,8,9

Answers were Sorted based on User's Feedback



There is a table1 with records (1,2,3,4,5,6) and table2 with records (4,5,6,7,8,9).write a query s..

Answer / john

select * from table1
union
select * from table2

-- Union will give distinct value of both tables

Is This Answer Correct ?    38 Yes 2 No

There is a table1 with records (1,2,3,4,5,6) and table2 with records (4,5,6,7,8,9).write a query s..

Answer / amit

select * from table1
union
select * from table2

Is This Answer Correct ?    21 Yes 5 No

There is a table1 with records (1,2,3,4,5,6) and table2 with records (4,5,6,7,8,9).write a query s..

Answer / alka

say table1 has col1 & table2 has col1 column

select col1 from table1
union
select col2 from table2

Is This Answer Correct ?    8 Yes 4 No

There is a table1 with records (1,2,3,4,5,6) and table2 with records (4,5,6,7,8,9).write a query s..

Answer / sushama kumari

select col1,col2 from table1 union table2 is an incorrect
answer.
Following 2 are corrcet answers:
1.
select * from table1
union
select * from table2
2.

select col1 from table1
union
select col2 from table2

Is This Answer Correct ?    2 Yes 1 No

There is a table1 with records (1,2,3,4,5,6) and table2 with records (4,5,6,7,8,9).write a query s..

Answer / aparna

here is some thing diff answer ..
we can use full outer join...if they ask for other then
union condition..
select * from t1 full outer join t2 where t1.id= t2.id..
with some condition

Is This Answer Correct ?    2 Yes 1 No

There is a table1 with records (1,2,3,4,5,6) and table2 with records (4,5,6,7,8,9).write a query s..

Answer / naveen

For Oracle it would be

select * from table1
union all
select * from table2

if you will use

select * from table1
union
select * from table2

it will give you double rows those are common in both the
tables.

Is This Answer Correct ?    1 Yes 1 No

There is a table1 with records (1,2,3,4,5,6) and table2 with records (4,5,6,7,8,9).write a query s..

Answer / jagadeesh

select isnull(a.id,b.id) from table1 a
full outer join table2 b
on a.id=b.id

Is This Answer Correct ?    1 Yes 1 No

There is a table1 with records (1,2,3,4,5,6) and table2 with records (4,5,6,7,8,9).write a query s..

Answer / anil

select * from table1

union

select * from table2

Is This Answer Correct ?    1 Yes 1 No

There is a table1 with records (1,2,3,4,5,6) and table2 with records (4,5,6,7,8,9).write a query s..

Answer / meghag

Also, use order by clause with union

Is This Answer Correct ?    0 Yes 0 No

There is a table1 with records (1,2,3,4,5,6) and table2 with records (4,5,6,7,8,9).write a query s..

Answer / goutam dey

its very easy yaar who has written this?
just use union operator as in set theory in mathematics
hahaha...

Is This Answer Correct ?    1 Yes 7 No

Post New Answer

More SQL Server Interview Questions

How to write a query with a full outer join in ms sql server?

0 Answers  


Do you know hot add cpu in sql server 2008?

0 Answers  


What is mean by clustered index and non clustered index, give syntax of creation? : sql server database administration

0 Answers  


Explain about protocol layer present in SQL server?

0 Answers  


What is exporting utility?

0 Answers  






What is trigger in salesforce?

0 Answers  


What do you understand by the data quality services in sql server?

0 Answers  


What are the different ways you can create databases in sql server?

0 Answers  


explain what are the steps you will take, if you are tasked with securing an sql server? : Sql server database administration

0 Answers  


You want to be sure that queries in a database always execute at the maximum possible speed. To achieve this goal you have created various indexes on tables which other statement will keep the database in good condition?

0 Answers  


What is difference between createstatement and preparedstatement?

0 Answers  


What is the difference between online clustering and Offline clustering?

0 Answers   IBM,


Categories