What is the difference between join and union.

Answer Posted / tanu

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.

EXAMPLE:
SELECT first_name
,last_name
,'employee' (TITLE 'employee//type')
FROM employee
WHERE manager_employee_number = 1019
UNION
SELECT first_name
,last_name
,' manager '
FROM employee
WHERE employee_number = 1019
ORDER BY 2
;

RESULT:

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

JOIN:
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 ?    11 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is difference between delete and truncate commands? : Sql dba

575


How many disk partitions should I have?

550


Do prepared statements prevent sql injection?

526


What do you understand by case manipulation functions?

541


What is before trigger?

552






Why truncate is used in sql?

527


what is a tablespace? : Sql dba

560


How do I run a sql trace?

520


What do we need to check in database testing?

554


What is the need of a partition key?

531


What is sql*plus?

566


How to use distinct and count in sql query? Explain

605


What is %rowtype in pl sql?

511


What are the types pl/sql code blocks?

609


What is nvl?

611