Types of joins ?

Answer Posted / rekha d rathnam

1.Cross Join - is a join without a join contition
SELECT * FROM table-1 CROSS JOIN table-2

2.Inner Join - return only matched records
i.Equi-Join
ii.Non-Equi Join
* Inner joins or equi joins are the most common type of
joins, they use equality "=" of common attributes to join
tables.
SELECT projects.name AS "Project Name", teachers.name
FROM teachers, projects
WHERE teachers.id = projects.teacher;

* Like an inner join, but with an operator different
from "=" in the condition, e.g., not equal "<>".
SELECT projects.name AS "Project Name", teachers.name
FROM teachers, projects
WHERE teachers.id != projects.teacher;

3.Outer Join
i.Full Outer Join
11.Left Outer Join
iii.Right Outer Join
LEFT -- only unmatched rows from the left side table (table-
1) are retained
RIGHT -- only unmatched rows from the right side table
(table-2) are retained
FULL -- unmatched rows from both tables (table-1 and table-
2) are retained
SELECT assign.project, projects.name, assign.percentage
FROM projects LEFT OUTER JOIN assign
ON projects.id = assign.project ;

4.Self Join - With table aliases you can join a table to
itself.
SELECT DISTINCT *
FROM assign a, assign b
WHERE a.stud = 2 AND b.stud = 4 AND a.project = b.project;

5.Multi Join - The number of tables involved in a join are
not restricted.
SELECT DISTINCT assign.project, projects.name AS "Project",
assign.percentage, stud.name AS "Student"
FROM projects, assign, stud
WHERE projects.id = 1 AND projects.id = assign.project
AND assign.stud = stud.id ;

Is This Answer Correct ?    13 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we have two clustered index on a table?

556


how to use 'mysql' to run sql statements? : Sql dba

535


How many joins in sql?

542


What plvcmt and plvrb does in pl/sql?

867


Write the alter statement to enable all the triggers on the t.students table.

657






How do you update a table in sql?

516


What is multiple columns?

567


What are types of joins?

529


what are the difference between clustered and a non-clustered index? : Sql dba

517


create SQL (both DML/DDL) statements appropriate for the creation of relational structures & constraints and other objects for a given case study, the population of these tables and the manipulation (querying/updating) of the stored data. 2. Create, develop and use the PL / SQL Program Units Procedures, Functions as a progression towards Object Oriented Relational Database Programming. 3. Package a collection of logically related Procedures and Functions together to further move towards development of Objects which reflect the principle of Data Abstraction whereby only an Object specified in the Interface is accessible to the end user. 4. Select, create, and use appropriate Database Triggers to impose agreed specific constraints on a Database Table. 5. Provide a full and detailed evaluation which includes a comprehensive test execution plan and its implementation for each of the above. Consider the following case study: Perilous Printing is a medium size printing company that does work for book publishers throughout UK. The company currently has 10 offices, most of which operate autonomously, apart from salaries, which are paid by the head office. Currently the sharing and communication of data, is carried out using multi- user networked access to a centralised RDBMS. Perilous Printing jobs consist of printing books or part of books. A printing job requires the use of materials, such as paper and ink, which are assigned to a job via purchase orders. Each printing job may have several purchase orders assigned to it. Likewise, each purchase order may contain several purchase order items. The following tables form part of the transactional RDB that the company uses: office (office_no, o_addr, o_telno, o_faxno, mgr_nin) staff (staff_no, nin, fname, lname, s_addr, s_telno, gender, dob, position, taxcode, salary, office_no) publisher (pub_no, p_name, p_city, p_telno, p_faxno, credit_code, office_no) book_job (job_no, pub_no, job_date, job_desc, job_type, job_status, supervisor_nin) purchase_order (job_no, po_no, po_date) po_item (job_no, po_no, it_no, qty) item (it_no, it_desc, amt_in_stock, price) office contains details of each office and the office number (office_no) is the key. Each office has a Manager represented by the manager’s national insurance number (mgr_nin). staff contains details of staff; the staff_no is the key. The office that the member of staff works from is given by office_no. publisher contains details of publisher and the publisher number (pub_no) is the key. Publishers are registered with the nearest office in their country, given by office_no, and they are given a credit code that can have the values “AA”, “AB”, “BB”, “BC”, “CC”, “CD” and “DD”. If a publisher is to be deleted then not only the publisher’s entry from the publisher table will have to be removed but all the data associated with the particular supplier has to be deleted too book_job contains details of publishing jobs and the job number (job_no) is the key. The publisher is given by the publisher number (pub_no) and the supervisor for the job by supervisor_nin. The job type can be either null or urgent; whereas the job_status can be “ongoing” or “completed” purchase_order contains details of the purchase orders for each job and the combination of job number and a purchase order number (job_no, po_no) form the key. Each printing job may have several purchase orders assigned to it. item contains details of all materials that can be used in printing jobs and the item number (it_no) is the key. po_item contains details of the items on the purchase order and (job_no, po_no, it_no) forms the key. In the above given database schema, descriptions are strings of characters (at most 30 characters long), any dates (except the job_ date) stored cannot be after the current system date, and quantities and prices are assumed to be non-negative numbers.

2317


How to avoid using cursors?

589


What is view? Can we update view

859


Which kind of parameters cannot have a default value in pl sql?

587


Define concurrency control. : Transact sql

582


What are all types of user defined functions?

520