0% found this document useful (0 votes)
4 views

Dbms Exp6

The document outlines an experiment aimed at implementing various SQL JOIN operations to merge data from multiple tables. It details the purpose, syntax, and examples of different types of joins, including Natural Join, Inner Join, Left Outer Join, and Right Outer Join. The conclusion emphasizes the importance of using these JOIN types for accurate and optimized query results.

Uploaded by

aryanshetty840
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Dbms Exp6

The document outlines an experiment aimed at implementing various SQL JOIN operations to merge data from multiple tables. It details the purpose, syntax, and examples of different types of joins, including Natural Join, Inner Join, Left Outer Join, and Right Outer Join. The conclusion emphasizes the importance of using these JOIN types for accurate and optimized query results.

Uploaded by

aryanshetty840
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Branch/Class/Batch:

Student Roll no.:


Student Name:

EXPERIMENT NUMBER: 6
AIM: Implement various Join operations.

OBJECTIVES: Efficiently merge data from multiple tables using different JOIN types to
ensure accurate, optimized, and meaningful query results.

THEORY: In SQL, joins are used to combine rows from two or more tables based on a
related column between them. The basic idea behind joins is that relational databases store
data across multiple tables to maintain efficiency, structure, and data integrity. Joins allow
you to combine this data to retrieve meaningful results by relating the data from different
tables.

Types of Joins:

1. Natural Join
i) Purpose: A NATURAL JOIN automatically joins tables based on all columns with
the same name in both tables. It eliminates duplicate columns from the result.

ii) Syntax: SELECT [column1, column2, ...] FROM table1 NATURAL JOIN table2;

iii) Example: SELECT * FROM employees NATURAL JOIN departments;

2. Simple Join or Inner Join


i) Purpose: A JOIN (commonly referred to as an INNER JOIN) combines rows from
two tables where there is a match in both tables based on a condition.

ii) Syntax: SELECT [column1, column2, ...] FROM table1 JOIN table2 ON
table1.common_column = table2.common_column;

iii) Example: SELECT employees.name, departments.department_name FROM


employees JOIN departments ON employees.department_id =
departments.department_id;

3. Left Outer Join


i) Purpose: A LEFT JOIN returns all records from the left table (table1) and the
matched records from the right table (table2). If no match is found, NULL values are
returned for columns from the right table.

ii) Syntax: SELECT [column1, column2, ...] FROM table1 LEFT JOIN table2 ON
table1.common_column = table2.common_column;

iii) Example: SELECT employees.name, departments.department_name FROM


employees LEFT JOIN departments ON employees.department_id =
departments.department_id;

4. Right Outer Join


i) Purpose: A RIGHT JOIN returns all records from the right table (table2) and the matched
records from the left table (table1). If no match is found, NULL values are returned for
columns from the left table.

ii) Syntax: SELECT [column1, column2, ...] FROM table1 RIGHT JOIN table2 ON
table1.common_column = table2.common_column;
iii) Example: SELECT employees.name, departments.department_name FROM
employees RIGHT JOIN departments ON employees.department_id =
departments.department_id;

CONCULSION: In this experiment, we explored the use of different SQL JOIN types to
efficiently merge data from multiple tables, with a focus on ensuring accurate, optimized,
and meaningful query results.

OUTPUT:

You might also like