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

DBMS Seminar

The document explains SQL Joins and Sub-Queries, detailing how Joins combine data from multiple tables based on common fields. It describes four types of Joins: INNER JOIN, LEFT JOIN, RIGHT JOIN, and CROSS JOIN, along with their functionalities. Additionally, it defines Sub-Queries, their types, and their use in SQL statements to further filter data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

DBMS Seminar

The document explains SQL Joins and Sub-Queries, detailing how Joins combine data from multiple tables based on common fields. It describes four types of Joins: INNER JOIN, LEFT JOIN, RIGHT JOIN, and CROSS JOIN, along with their functionalities. Additionally, it defines Sub-Queries, their types, and their use in SQL statements to further filter data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Sub-Queries & Joins

IN SQL

Aniketh.V
11209A021
WHAT ARE JOINS ?
SQL Join statement is used to combine data or
rows from two or more tables based on a
common field between them.

COMBINE ROWS FROM TWO OR MORE TABLES

Different types of Joins are as follows:


• INNER JOIN
• LEFT JOIN
• RIGHT JOIN
• CROSS JOIN
TYPES OF JOINS?

• INNER JOIN: Returns records that having common values.

• RIGHT JOIN: Return all records from the right table and matched
records
from left table.

• LEFT JOIN: Return all records from the left table and matched records
from right table.

• CROSS JOIN: It returns the cartesian product of the no:of columns in


first
table to no:of rows of second table.
TABLE NAME: J1
SNO NAME AGE SALARY
1 ROY 20 100
2 DAN 25 150
3 CHALLA 23 2000

TABLE NAME: J2
SNO NAME AGE SALARY
4 EDEN 30 200
2 DAN 25 150
5 TOM 28 1903

Example for Joins:


INNER JOIN
RIGHT JOIN
LEFT JOIN
CROSS (CARTESIAN) JOIN
WHAT IS A SUB-
QUERY
• A subquery? is used to return data that will
be used in the main query as a condition to
further restrict the data to be retrieved.

A QUERY WITHIN A QUERY IS KNOWN AS SUB-


QUERY
• Subqueries can be used with the SELECT,
INSERT, UPDATE, and DELETE statements
along with the operators like =, <, >, >=,
<=, IN, BETWEEN, etc.
TYPES OF SUB-QUERIES?

• SUBQURIES RETURING ONE ROW : A Query that returns only one


row at a time.
• SUBQURIES RETURING MULTIPLE ROWS: A Query that returns
multiple
row at a time.

• CORELATED SUBQUERY: A Query that is related to two deferent


data
or two tables.
TABLE NAME: J1
SNO NAME AGE SALARY
1 ROY 20 100
2 DAN 25 150
3 CHALLA 23 2000
4 REN 25 1000
TABLE NAME: J2
SNO NAME AGE SALARY
4 EDEN 30 200
2 DAN 25 150
5 TOM 28 1903

Example for Sub-Queries:


SUBQURIES RETURING ONE ROW
UBQURIES RETURING MULTIPLE ROWS
CORELATED SUBQUERY
THANK YOU!!!

You might also like