What are joins..how many types of joins are there?
Answer Posted / venu
types of joins:
• Equijoin
• Non-equijoin
• Outer join
• Self join
Equijoins:
-------------
To determine an employee’s department name, you compare the
value in the DEPARTMENT_ID
column in the EMPLOYEES table with the DEPARTMENT_ID values
in the DEPARTMENTS table.
The relationship between the EMPLOYEES and DEPARTMENTS
tables is an equijoin—that is, values
in the DEPARTMENT_ID column on both tables must be equal.
Frequently, this type of join involvesprimary and foreign
key complements.
SELECT employees.employee_id, employees.last_name,
employees.department_id, departments.department_id,
departments.location_id
FROM employees, departments
WHERE employees.department_id = departments.department_id;
Non-Equijoins:
----------------
A non-equijoin is a join condition containing something
other than an equality operator.
The relationship between the EMPLOYEES table and the
JOB_GRADES table has an
example of a non-equijoin. A relationship between the two
tables is that the SALARY
column in the EMPLOYEES table must be between the values in
the LOWEST_SALARY
and HIGHEST_SALARY columns of the JOB_GRADES table. The
relationship is
obtained using an operator other than equals (=).
SELECT e.last_name, e.salary, j.grade_level
FROM employees e, job_grades j
WHERE e.salary
BETWEEN j.lowest_sal AND j.highest_sal;
Outer Joins:
---------------
The missing rows can be returned if an outer join operator
is used in the join condition. The operator
is a plus sign enclosed in parentheses (+), and it is
placed on the “side” of the join that is deficient in
information. This operator has the effect of creating one
or more null rows, to which one or more rows
from the nondeficient table can be joined.
SELECT e.last_name, e.department_id, d.department_name
FROM employees e, departments d
WHERE e.department_id(+) = d.department_id ;
Self Joins:
-------------
Joining a Table to Itself
Sometimes you need to join a table to itself. To find the
name of each employee’s manager, you need
to join the EMPLOYEES table to itself, or perform a self
join.
SELECT worker.last_name || ’ works for ’
|| manager.last_name
FROM employees worker, employees manager
WHERE worker.manager_id = manager.employee_id ;
Is This Answer Correct ? | 32 Yes | 13 No |
Post New Answer View All Answers
What is format trigger?
Differentiate between post-database commit and post-form commit?
What is backup in Oracle?
Why does Oracle not permit the use of PCTUSED with indexes?
How different is ms access and oracle?
How to turn on or off recycle bin for the instance?
What are the different types of record groups in oracle? Explain each of them
How to revoke create session privilege from a user in oracle?
What is a partition in oracle?
What is a cursor in oracle?
What query tells you how much space a tablespace named test is taking up, and how much space is remaining?
1) WIll all the user get the DEFAULT profile, if their current profile got deleted at any point of time? 2) What are the Situation we need to MOVE the TABLE between T.spaces? 3) What is the use of MOVING the TABLE between SCHEMA'S? 4) What are the Table Clause, Segment Clause and the Datafile Clause which will override each other? 5) Explain SORT_AREA_SIZE of Tempfile to make UNIFORM SIZE
How to do paging with oracle?
What are nested tables?
How to select all columns of all rows from a table in oracle?