SlideShare a Scribd company logo
1 of 16
JOINS AND SUBQUERIES IN
BIG DATAANALYSIS
N.SURATHAVANI MSc(IT)
Nadar Saraswathi College of Arts and Science,
Theni.
SQL JOIN:
A JOIN clause is used to combine rows from two or
more tables, based on a related column between them.
An SQL JOIN clause combines rows from two or
more tables. It creates a set of rows in a temporary
table.
Different Types of SQL JOINs:
JOIN (INNER)
LEFT (OUTER) JOIN
RIGHT (OUTER) JOIN
FULL (OUTER) JOIN
SQL INNER JOIN:
The INNER JOIN keyword selects records that have
matching values in both tables.
The INNER JOIN keyword selects all rows from
both tables as long as there is a match between the
columns.
INNER JOIN Syntax:
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
SQL LEFT JOIN:
The LEFT JOIN keyword returns all records from
the left table (table1), and the matched records from
the right table (table2).
The result is NULL from the right side, if there is no
match.
The LEFT JOIN keyword returns all records from
the left table (Customers), even if there are no
matches in the right table (Orders).
LEFT JOIN Syntax:
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name = table2.column_name;
SQL RIGHT JOIN:
The RIGHT JOIN keyword returns all records from
the right table (table2), and the matched records from
the left table (table1).
The result is NULL from the left side, when there is
no match.
The RIGHT JOIN keyword returns all records from
the right table (Employees), even if there are no
matches in the left table (Orders).
RIGHT JOIN Syntax:
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name = table2.column_name;
SQL FULL OUTER JOIN:
The FULL OUTER JOIN keyword return all records
when there is a match in either left (table1) or right
(table2) table records.
FULL OUTER JOIN can potentially return very
large result-sets.
FULL OUTER JOIN and FULL JOIN are the same.
FULL OUTER JOIN Syntax:
SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name = table2.column_name
WHERE condition;
Subquery in SQL:
The subquery can be nested inside a SELECT,
INSERT, UPDATE, or DELETE statement or inside
another subquery.
A subquery is usually added within the WHERE
Clause of another SQL SELECT statement.
You can use the comparison operators, such as >, <,
or =. The comparison operator can also be a multiple-
row operator, such as IN, ANY, or ALL.
A subquery is also called an inner query or inner
select, while the statement containing a subquery is
also called an outer query or outer select.
A subquery must be enclosed in parentheses.
A subquery must be placed on the right side of the
comparison operator.
A subquery may occur in :
A SELECT clause
A FROM clause
A WHERE clause
Subqueries:
A subquery must be enclosed in parentheses.
A subquery must be placed on the right side of
the comparison operator.
Subqueries cannot manipulate their results
internally, therefore ORDER BY clause cannot
be added into a subquery.
Use single-row operators with single-row
subqueries

More Related Content

What's hot (20)

MySQL Data types
MySQL Data typesMySQL Data types
MySQL Data types
 
SQL
SQLSQL
SQL
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
SQL JOIN
SQL JOINSQL JOIN
SQL JOIN
 
Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Group By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLGroup By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQL
 
Sql commands
Sql commandsSql commands
Sql commands
 
Joins in dbms and types
Joins in dbms and typesJoins in dbms and types
Joins in dbms and types
 
DML Commands
DML CommandsDML Commands
DML Commands
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Triggers in SQL | Edureka
Triggers in SQL | EdurekaTriggers in SQL | Edureka
Triggers in SQL | Edureka
 
SQL Joins With Examples | Edureka
SQL Joins With Examples | EdurekaSQL Joins With Examples | Edureka
SQL Joins With Examples | Edureka
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
 
joins in database
 joins in database joins in database
joins in database
 
2.0 sql data types for my sql, sql server
2.0 sql data types for my sql, sql server2.0 sql data types for my sql, sql server
2.0 sql data types for my sql, sql server
 

Similar to joins and subqueries in big data analysis

Similar to joins and subqueries in big data analysis (20)

JOINS.pptx
JOINS.pptxJOINS.pptx
JOINS.pptx
 
V19 join method-c
V19 join method-cV19 join method-c
V19 join method-c
 
Joining
JoiningJoining
Joining
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
Join in SQL - Inner, Self, Outer Join
Join in SQL - Inner, Self, Outer JoinJoin in SQL - Inner, Self, Outer Join
Join in SQL - Inner, Self, Outer Join
 
database .pptx
database .pptxdatabase .pptx
database .pptx
 
SQL JOIN.pptx
SQL JOIN.pptxSQL JOIN.pptx
SQL JOIN.pptx
 
types of SQL Joins
 types of SQL Joins types of SQL Joins
types of SQL Joins
 
Sql joins inner join self join outer joins
Sql joins inner join self join outer joinsSql joins inner join self join outer joins
Sql joins inner join self join outer joins
 
Sql slid
Sql slidSql slid
Sql slid
 
Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01
 
Joins & constraints
Joins & constraintsJoins & constraints
Joins & constraints
 
Assignment 4
Assignment 4Assignment 4
Assignment 4
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
Join query
Join queryJoin query
Join query
 
Join sql
Join sqlJoin sql
Join sql
 
Joins
JoinsJoins
Joins
 
SQL
SQLSQL
SQL
 
Unit_9.pptx
Unit_9.pptxUnit_9.pptx
Unit_9.pptx
 
Mysql joins
Mysql joinsMysql joins
Mysql joins
 

More from SanSan149

Sdma fdma-tdma-fixed tdm
Sdma fdma-tdma-fixed tdmSdma fdma-tdma-fixed tdm
Sdma fdma-tdma-fixed tdmSanSan149
 
Histogram process spatial filtering
Histogram process spatial filteringHistogram process spatial filtering
Histogram process spatial filteringSanSan149
 
Mobile computing vani
Mobile computing vaniMobile computing vani
Mobile computing vaniSanSan149
 
Telecommunication system gms mobile service
Telecommunication system gms mobile serviceTelecommunication system gms mobile service
Telecommunication system gms mobile serviceSanSan149
 
Adaptive filters and band reject filters
Adaptive filters and band reject filtersAdaptive filters and band reject filters
Adaptive filters and band reject filtersSanSan149
 
SDMA-FDMA-TDMA-fixed TDM
SDMA-FDMA-TDMA-fixed TDMSDMA-FDMA-TDMA-fixed TDM
SDMA-FDMA-TDMA-fixed TDMSanSan149
 
Hadoop storage
Hadoop storageHadoop storage
Hadoop storageSanSan149
 
Normalization
NormalizationNormalization
NormalizationSanSan149
 
Manageral aspects of software maintance
Manageral aspects of software maintanceManageral aspects of software maintance
Manageral aspects of software maintanceSanSan149
 
Common language runtime clr
Common language runtime clrCommon language runtime clr
Common language runtime clrSanSan149
 

More from SanSan149 (11)

Sdma fdma-tdma-fixed tdm
Sdma fdma-tdma-fixed tdmSdma fdma-tdma-fixed tdm
Sdma fdma-tdma-fixed tdm
 
Histogram process spatial filtering
Histogram process spatial filteringHistogram process spatial filtering
Histogram process spatial filtering
 
Mobile computing vani
Mobile computing vaniMobile computing vani
Mobile computing vani
 
Telecommunication system gms mobile service
Telecommunication system gms mobile serviceTelecommunication system gms mobile service
Telecommunication system gms mobile service
 
Adaptive filters and band reject filters
Adaptive filters and band reject filtersAdaptive filters and band reject filters
Adaptive filters and band reject filters
 
Hema rdbms
Hema rdbmsHema rdbms
Hema rdbms
 
SDMA-FDMA-TDMA-fixed TDM
SDMA-FDMA-TDMA-fixed TDMSDMA-FDMA-TDMA-fixed TDM
SDMA-FDMA-TDMA-fixed TDM
 
Hadoop storage
Hadoop storageHadoop storage
Hadoop storage
 
Normalization
NormalizationNormalization
Normalization
 
Manageral aspects of software maintance
Manageral aspects of software maintanceManageral aspects of software maintance
Manageral aspects of software maintance
 
Common language runtime clr
Common language runtime clrCommon language runtime clr
Common language runtime clr
 

Recently uploaded

Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 

Recently uploaded (20)

Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 

joins and subqueries in big data analysis

  • 1. JOINS AND SUBQUERIES IN BIG DATAANALYSIS N.SURATHAVANI MSc(IT) Nadar Saraswathi College of Arts and Science, Theni.
  • 2. SQL JOIN: A JOIN clause is used to combine rows from two or more tables, based on a related column between them. An SQL JOIN clause combines rows from two or more tables. It creates a set of rows in a temporary table.
  • 3. Different Types of SQL JOINs: JOIN (INNER) LEFT (OUTER) JOIN RIGHT (OUTER) JOIN FULL (OUTER) JOIN
  • 4. SQL INNER JOIN: The INNER JOIN keyword selects records that have matching values in both tables. The INNER JOIN keyword selects all rows from both tables as long as there is a match between the columns.
  • 5. INNER JOIN Syntax: SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name = table2.column_name;
  • 6. SQL LEFT JOIN: The LEFT JOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2). The result is NULL from the right side, if there is no match. The LEFT JOIN keyword returns all records from the left table (Customers), even if there are no matches in the right table (Orders).
  • 7. LEFT JOIN Syntax: SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name = table2.column_name;
  • 8. SQL RIGHT JOIN: The RIGHT JOIN keyword returns all records from the right table (table2), and the matched records from the left table (table1). The result is NULL from the left side, when there is no match. The RIGHT JOIN keyword returns all records from the right table (Employees), even if there are no matches in the left table (Orders).
  • 9. RIGHT JOIN Syntax: SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name = table2.column_name;
  • 10. SQL FULL OUTER JOIN: The FULL OUTER JOIN keyword return all records when there is a match in either left (table1) or right (table2) table records. FULL OUTER JOIN can potentially return very large result-sets. FULL OUTER JOIN and FULL JOIN are the same.
  • 11. FULL OUTER JOIN Syntax: SELECT column_name(s) FROM table1 FULL OUTER JOIN table2 ON table1.column_name = table2.column_name WHERE condition;
  • 12. Subquery in SQL: The subquery can be nested inside a SELECT, INSERT, UPDATE, or DELETE statement or inside another subquery. A subquery is usually added within the WHERE Clause of another SQL SELECT statement. You can use the comparison operators, such as >, <, or =. The comparison operator can also be a multiple- row operator, such as IN, ANY, or ALL.
  • 13. A subquery is also called an inner query or inner select, while the statement containing a subquery is also called an outer query or outer select. A subquery must be enclosed in parentheses. A subquery must be placed on the right side of the comparison operator.
  • 14. A subquery may occur in : A SELECT clause A FROM clause A WHERE clause
  • 15.
  • 16. Subqueries: A subquery must be enclosed in parentheses. A subquery must be placed on the right side of the comparison operator. Subqueries cannot manipulate their results internally, therefore ORDER BY clause cannot be added into a subquery. Use single-row operators with single-row subqueries