:: 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                      
Categories >> Software >> Databases >> SQL PLSQL


 Oracle interview questions  Oracle Interview Questions (2040)
 SQL Server interview questions  SQL Server Interview Questions (1080)
 MS Access interview questions  MS Access Interview Questions (25)
 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 (775)
 Databases AllOther interview questions  Databases AllOther Interview Questions (107)
What is the difference between join and union.
 Question Submitted By :: SQL-PLSQL
I also faced this Question!!     Answer Posted By  
# 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 ?    246 Yes 115 No
# 2
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

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 ?    90 Yes 15 No
Somashekhar M
# 3

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.


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

Now for performing a JOIN type the query shown below

SELECT articleno, article, manufacturer
FROM t1 JOIN t2 ON (t1.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
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 ?    74 Yes 7 No
Blue Shark
# 4
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 ?    114 Yes 48 No
Nand Kumar
# 5
A join selects columns from 2 or more tables. A union
selects rows
Is This Answer Correct ?    110 Yes 59 No
# 6
A join selects columns from 2 or more tables.
a union selects rows
Is This Answer Correct ?    51 Yes 17 No
Vinay Shukla
# 7

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.


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 ?    28 Yes 8 No
# 8
A Union and Join are similar in that they both are combining
two tables to form another table. However they do this
combining in different ways. The geometry is different.

Lets say for Table A and Table B
Union : -

Join : - -
| A | B |
- -

Union :
(1) In Union Two Rows of one table must fit onto the other
table. The Number of columns in the result table is the same
as the number in both tables. No new Columns are added.

(2) Maximum Number of rows = Sum of Number of rows in the
two tables.

Join :
(1) In Join the rows of one table may be different from the
rows of another table. The result table can contain columns
from both the first and second tables. It can contain all
the columns of first table and all the columns of second tables.

(2) Maximum Number of rows = Product of rows in two tables.
Is This Answer Correct ?    19 Yes 2 No
Uchit Shah
# 9
UNION: Union Combines results of all select statements,
displaying duplicate rows only one time in the answerset.

Rules for usage:
1. All select clauses must have same number of expressions.
2. Corresponding expressions must have compatible domains.

First SELECT statement:
->Determines output format.
->Determines output title.

Last SELECT statement:
->Contains ORDER BY for the entire result, if required.

SELECT first_name
,'employee' (TITLE 'employee//type')
FROM employee
WHERE manager_employee_number = 1019
SELECT first_name
,' manager '
FROM employee
WHERE employee_number = 1019


first_name last_name employee_type
Carol Kanieski employee
Ron Kubic manager
John Stein employee

Join is a technique for accessing data from more than one
table in a single answerset. Each row in the answerset may
contain data from columns of more than one table. Tables
are joined on columns sharing common domain.
Is This Answer Correct ?    5 Yes 2 No
# 10
join is used to combine two different tables where as in union

union also perform the same operation but the difference is
union will return distinct(unique) values.we can eliminate
the duplicate records while using union
Is This Answer Correct ?    3 Yes 1 No

Other SQL PLSQL Interview Questions
  Question Asked @ Answers
What is magic table?   6
Can we have exception part in trigger ?   1
write the Sql query for creating database backup? TCS 7
How to write a procedure for displying the data in a TREE or (PARENT and CHILD ) relationship , for ex: A is the main project id, for this project B,C,D are sub tasks(sub project id's) for B the sub tasks are e,f,g and for c is h ,i ,j and for d is k,l,m now i need to display the o/p in a TREE fashion pls help me , thanks in advance surendra Zensar 2
What are the types of triggers ? TCS 25
How many levels can subqueries be nested in a FROM clause?   7
how to sort records in sql?   3
Can we use SQL%ISOPEN in implicit cursors? Does this attribute works properly in Implicit Curosors?   3
how can i read write files from pl/sql   3
Authentication mechanisms in Sql Server ? BirlaSoft 1
suppose I have two table one Emp and other is dpt. Emp table has a field ,dept id,name ,sal and dpt table has a field dept id,dept name. Now I want to find out the emplyee list whose sal is between 2000-3000 from dept x. Geometric-Software 6
write a pl/sql function if enter a value=0 then output value=1 and vise verse with out using if and case statements. Zensar 1
For more SQL PLSQL Interview Questions Click Here 

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