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
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 |
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 |
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 |
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 |
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 |
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 |
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 |
What is referential integrity? What are the advantages of it?
4 Answers Descon, Digital Domain,
How to verify a login name with sqlcmd tool?
what are the problems in logshipping?
How do you find the number of rows in a table?
How do I schedule a sql server profiler trace?
How to read 2nd highest sal from EMP table?
Explain about extended stored procedure?
What is the difference between local and global temporary tables?
How to create logins using windows Authentication mode?
What is a Linked Server?
What is etl - extraction, transformation, and loading?
Normalization and denormalization
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)