Professional Documents
Culture Documents
Dbms 7
Dbms 7
ame:
N
Class:
Div:
Roll
no:
DOP:
DOS:
Grade
Sign:
Aim:To perform join operation using SQL
heory:
T
Types of joins-
1.CROSS JOIN
2.INNER JOIN
3.OUTER JOIN-
i-LEFT OUTER
ii-RIGHT OUTER
iii-FULL OUTER
1.CROSS JOIN
efinition:ACROSSJOINinSQLisajoinoperationthatcombineseachrowofthefirst
D
tablewitheveryrowofthesecondtable,resultinginwhatiscalledtheCartesianproduct
of the two tables. This means that for every row in the first table, there will be a
corresponding row for each row in the second table. It is essentiallyawaytocreateall
possible combinations of rows from the two tables.
Syntax:
ELECT * FROM table1
S
CROSS JOIN table2;
Querry:
Output:
1-INNER JOIN:
nINNERJOINinSQLisatypeofjoinusedtocombinerowsfromtwoormoretables
A
based on a related column or columns between them. It selects only the rowsthathave
matching values in thespecifiedcolumnsfrombothtables,effectivelyfilteringoutrows
where there is no match. This type of join is particularly useful for retrieving data that
exists in both tables and is often used toconnectrelateddataacrossmultipletablesina
relationaldatabase.TheINNERJOINoperationresultsinanewtablewithcolumnsfrom
both tables, containing only the rows that satisfy the join condition. It helps increating
meaningful relationships between tables and retrieving relevant data for analysis or
reporting purposes.
YNTAX:
S
SELECT columns
FROM table1
INNER JOIN table2 ON table1.column = table2.column;
UTER JOIN: Outer joins in SQL are essential for fetching data from multiple tables,
O
even whentheremightnotbematchingrecordsinoneorbothtables.Thesejoinscomein
three varieties: LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN.
IGHT OUTER JOIN returns all records from the right table and matching recordsfrom
R
the left table, or NULL if no match is found in
ULL OUTER JOIN : returns aresultsetthatincludesallrowsfrombothtablesbeingjoined,
F
regardless of whether there is a matchingrowintheothertable.Ifthereisnomatchforarow
from one table in theothertable,thecolumnsfromthenon-matchingtablewillcontainNULL
values in the result set.TheFULLOUTERJOINensuresthatnodataislostfromeithertable,
making it useful for scenarios where you need to include all records from both tables,evenif
they don't have matching values in the join condition.
Conclusion:
I n this experiment, we explored different types of SQL joins using the DVD Rental
Database. Through various join operations like INNER,LEFTOUTER,RIGHTOUTER,
FULL OUTER, and CROSS joins, we learnedhowtocombinedatafrommultipletables
efficiently. This exercise provided valuable insights into relational database querying,
highlighting the importance of understanding join types for effective data retrieval and
analysis.