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                      
tip   SiteMap shows list of All Categories in this site.
Google
   
 
Categories  >>  Software  >>  Databases  >>  SQL PLSQL
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
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 ?    197 Yes 96 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 ?    90 Yes 42 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 ?    94 Yes 52 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 ?    36 Yes 50 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 ?    19 Yes 28 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 ?    45 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 ?    77 Yes 12 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 ?    18 Yes 30 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 ?    23 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 ?    66 Yes 6 No
Blue Shark
 

 
 
 
Other SQL PLSQL Interview Questions
 
  Question Asked @ Answers
 
What are the return values of functions SQLCODE and SQLERRM ? PreVator2
Differentiate between %type and %rowtype attribute in Oracle PL/AQL programming ? PreVator6
Query for second maximum salary in each in each department TCS8
what is global temporary tables and how use that tables in pl/sql packages Cap-Gemini1
there is A table and B table in A table there 5 rows and in b table there are 2 rows i am firing query select * from a,b what will be the output? Cognizent7
can i give user defined exception in a package  2
If we have n no of columns in a table, can we add new column in that table with not null constraint?  2
I have the table like this S.No Name ID 01 Xyz 123 I want the result as 01Xyz123 How to write the query to retrieve the entire row data in a single column?  1
IN A TABLE HAVE ONE COLUMN PRIMARY KEY..IT WILL NOT ALLOWS NULL VALUES AND DUPLICATE VALUES..INSTEAD OF PRIMARY KEY WHY CANT WE USE UNIQUE AND NOT NULL.THESE TWO ALSO DOESNT ACCEPT NULL VALUES IN NOT NULL AND UNIQUE DOESNT ACCEPT DUPLICATE VALUES? SO WHAT IS THE DIFEERENCE BETWEEN(UNIQUE,NOT NULL) AND PRIMARY KEY?????? rsystems6
how to findout the 100th maximum salary AMDOC23
Types of cursors and explanation each of them ? DELL3
in materialized view the structure will create immediately or not? iFlex2
 
For more SQL PLSQL Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2012  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com