:: 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 (2041)
 SQL Server interview questions  SQL Server Interview Questions (1082)
 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 (54)
 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 ?    248 Yes 116 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 ?    92 Yes 16 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 ?    75 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 ?    112 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
suppose we have a table in which 200 rows. i want to find 101 row ? what the query.... and how we find 4th and 5th highest salary and 1 to 10 highest salary   7
how to create temparary sequence TCS 2
What is the difference between DELETE and TRUNCATE? Tech-Mahindra 15
write a query to delete similar records in particular fields(columns) in different tables TCS 6
I want to display the employees who have joined in last two months. (It should be executed randomly means If I execute the query in March it should display Jan and Feb joined employees. Same query if i execute in Feb, 2007 it should display dec, 2006 and jan 2007 joined employees. Wipro 12
What is the difference between sql/pl-sql/embeded sql?   3
what command is used to create a table by copying the structure of another table including constraints ? eicc 5
if i perform any operation on views such as insert, delete etc will my base table get affected?????   4
a procedure one in two out parameters i am waiting it in a sql query can i get the output   1
What is difference between CHAR and VARCHAR2?What is the maximum SIZE allowed for each type? Saama-Tech 6
What is a bitmap index? Choice-Solutions 4
SELECT category, type, AVG(price) FROM products GROUP BY category, type ORDER BY 1, 2 If there are three distinct categories in the "products" table, and each one has five different types, how many rows are returned by the query above? 1. 1 row 2. 3 rows 3. 5 rows 4. 8 rows 5. 15 rows   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.   ::