ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Databases >> SQL PLSQL
 
 


 

 
 Oracle interview questions  Oracle Interview Questions (2035)
 SQL Server interview questions  SQL Server Interview Questions (1075)
 MS Access interview questions  MS Access Interview Questions (24)
 MySQL interview questions  MySQL Interview Questions (194)
 Postgre interview questions  Postgre Interview Questions (6)
 Sybase interview questions  Sybase Interview Questions (22)
 DB Architecture interview questions  DB Architecture Interview Questions (5)
 DB Administration interview questions  DB Administration Interview Questions (213)
 DB Development interview questions  DB Development Interview Questions (53)
 SQL PLSQL interview questions  SQL PLSQL Interview Questions (768)
 Databases AllOther interview questions  Databases AllOther Interview Questions (106)
Question
What is the difference between join and union.
 Question Submitted By :: Dreamoracle
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the difference between join and union.
Answer
# 1
we can join two tables by 'join' if they have common
field.we can union two tables irrespective of common field.
 
Is This Answer Correct ?    230 Yes 106 No
Haritha
 
  Re: What is the difference between join and union.
Answer
# 2
Join is used to established a conditional selection from 2
different tables, while union is used to select similar
data based on different conditions.
 
Is This Answer Correct ?    108 Yes 44 No
Nand Kumar
 
 
 
  Re: What is the difference between join and union.
Answer
# 3
A join selects columns from 2 or more tables. A union
selects rows
 
Is This Answer Correct ?    102 Yes 55 No
Thangamadasamy
 
  Re: What is the difference between join and union.
Answer
# 4
A join is used to combine rows from multiple tables. A join
is performed whenever two or more tables is listed in the
FROM clause of an SQL statement.


Combines the results of two SELECT statements into one
result set, and then eliminates any duplicate rows from
that result set
 
Is This Answer Correct ?    39 Yes 54 No
Venki
 
  Re: What is the difference between join and union.
Answer
# 5
In Join, matching rows are joined side-by-side to make the
result table but whereas in Union rows are joined one-below
the other to make the result table.
 
Is This Answer Correct ?    20 Yes 29 No
Vijay Kulkarni
 
  Re: What is the difference between join and union.
Answer
# 6
A join selects columns from 2 or more tables.
a union selects rows
 
Is This Answer Correct ?    48 Yes 14 No
Vinay Shukla
 
  Re: What is the difference between join and union.
Answer
# 7
Union : The union operator combines the results of two or
more queries into a single result set. But no.of columns
must match in both/all the queries (and also the order)
which are used for union.
Union -- returns with no duplicate rows
Union all -- retruns with duplicate rows (No. of rows
returned = No. of rows in Query1 + No. of rows in Query 2)
Union is a set operator.
You cannot use the union operator within a create view
statement.

You cannot use the union operator on text and image columns.

You cannot use the for browse clause in statements
involving the union operator.

Joins: Joins are used to extract information from more than
one table based on the related column/coloums (PK and RFK)
any no. of rows can be retrived based on matching matching
colums. Different types of joins are Inner join=equi join=
join, outer join(Right outer join/right join, Left outer
join/ left join), Cross join, and full outer join/outer join
 
Is This Answer Correct ?    84 Yes 13 No
Somashekhar M
 
  Re: What is the difference between join and union.
Answer
# 8
Union:- Union return the common data in the form of rows

Join:- Joins always returncommon Data in the form of Column
if oyu have some suggetion about this then plz call
me at this is my no
+91-9868591907
 
Is This Answer Correct ?    19 Yes 34 No
Sat Kumar
 
  Re: What is the difference between join and union.
Answer
# 9
join:

The SQL JOIN clause is used whenever we have to select data
from 2 or more tables.
To be able to use SQL JOIN clause to extract data from 2
(or more) tables, we need a relationship between certain
columns in these tables.

union:

The purpose of the SQL UNION command is to combine the
results of two queries together. In this respect, UNION is
somewhat similar to JOIN in that they are both used to
related information from multiple tables. One restriction
of UNION is that all corresponding columns need to be of
the same data type. Also, when using UNION, only distinct
values are selected (similar to SELECT DISTINCT).
 
Is This Answer Correct ?    25 Yes 8 No
Lalitha
 
  Re: What is the difference between join and union.
Answer
# 10
JOIN:
-----

A Join is used for displaying columns with the same or
different names from different tables. The output displayed
will have all the columns shown individually. i.e. The
columns will be aligned next to each other.

UNION:
------

The UNION set operator is used for combining data from two
tables which have columns with the same datatype.
When a UNION is performed the data from both tables will be
collected in a single column having the same datatype.

For eg:

See the two tables shown below:

Table t1

Articleno article price manufacturer_id
1 hammer 3 $ 1
2 screwdriver 5 $ 2

Table t2
manufacturer_id manufacturer
1 ABC Gmbh
2 DEF Co KG

Now for performing a JOIN type the query shown below

SELECT articleno, article, manufacturer
FROM t1 JOIN t2 ON (t1.manufacturer_id =
t2.manufacturer_id);

articelno article manufacturer
1 hammer ABC GmbH
2 screwdriver DEF Co KG

That is a join.

UNION means that you have to tables or resultset with the
same amount and type of columns and you add this to
tables/resultsets together. Look at this example:

Table year2006

Articleno article price manufacturer_id
1 hammer 3 $ 1
2 screwdriver 5 $ 2

Table year2007

Articleno article price manufacturer_id
1 hammer 6 $ 3
2 screwdriver 7 $ 4

SELECT articleno, article, price, manufactruer_id
FROM year2006
UNION
SELECT articleno, article, price, manufacturer_id
FROM year2007

articleno article price manufacturer_id
1 hammer 3 $ 1
2 screwdriver 5 $ 2
1 hammer 6 $ 3
2 screwdriver 7 $ 4

Hope this helps!
 
Is This Answer Correct ?    70 Yes 6 No
Blue Shark
 

 
 
 
Other SQL PLSQL Interview Questions
 
  Question Asked @ Answers
 
How to convert ms-excel file to oracle table?   2
what is oracle sql,pl/sql with interfaces TCS 2
select sal from emp group by sal TCS 2
Write a query to find the employees from EMP table those who have joined in Monday. (there is a column as hiredate which is a date column i.e values are like 03-DEC-81)   3
if we give update table_name set column_name= default. what will happen? iFlex 4
what is the order of pre-defined exceptions. TCS 6
What is the difference between sql/pl-sql/embeded sql?   3
how to eliminate null values in a column i.e table vlaues 1 2 3 NULL 3 4 1 5 NULL i want output like this 1 2 3 3 4 1 5 i dnt want to use nvl is null and i dnt want replace the NULL value with any value i.e nvl(col,o); Satyam 9
Regarding joins what are the differences you observed in oracle 9i and sql server? Choice-Solutions 3
Differences between UNIQUE and DISTINCT in select statements Verinon-Technology-Solutions 25
Whate is use of MOD function in pl/sql. Oracle 3
sql query to get zero records from a table having n no of records CTS 7
 
For more SQL PLSQL Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com