SlideShare a Scribd company logo
5
Most read
10
Most read
13
Most read
MySQL JoinsMySQL Joins
MySQL Joins OverviewMySQL Joins Overview
 MySQL Join is used to join the records from twoMySQL Join is used to join the records from two
tables using join clause.tables using join clause.
 The Join Clause return you the set of records fromThe Join Clause return you the set of records from
both table on the basis of common column.both table on the basis of common column.
MySQL Join TypesMySQL Join Types
 MySQLMySQL Inner JoinInner Join
 MySQL Equi JoinMySQL Equi Join
 MySQL Natural JoinMySQL Natural Join
 MySQL Cross JoinMySQL Cross Join
 MySQL Outer JoinMySQL Outer Join
 Left Outer JoinLeft Outer Join
 Right Outer JoinRight Outer Join
 Self JoinSelf Join
 Inner joinInner join produces only the set of records that produces only the set of records that
match in both Table A and Table B.match in both Table A and Table B.
MySQL Inner JoinMySQL Inner Join
 The INNER JOIN keyword returns rows when thereThe INNER JOIN keyword returns rows when there
is at least one match in both tables.is at least one match in both tables.
 If there are rows in "Persons" that do not haveIf there are rows in "Persons" that do not have
matches in "Orders", those rows will NOT be listed.matches in "Orders", those rows will NOT be listed.
 Example:Example:
 SELECT Persons.LastName,SELECT Persons.LastName,
Persons.FirstName, Orders.OrderNoPersons.FirstName, Orders.OrderNo
FROM Persons INNER JOIN OrdersFROM Persons INNER JOIN Orders
ON Persons.P_Id = Orders.P_IdON Persons.P_Id = Orders.P_Id
ORDER BY Persons.LastNameORDER BY Persons.LastName
(Contd:)MySQL Inner JoinMySQL Inner Join
MySQL Outer JoinMySQL Outer Join
 MySQL Outer Join return you the set of all matchingMySQL Outer Join return you the set of all matching
records from both table.records from both table.
 The Outer Join does not requires each records to beThe Outer Join does not requires each records to be
matched in both the tables.matched in both the tables.
 MySQL Outer Join is categorized into two groups.MySQL Outer Join is categorized into two groups.
 MySQL Left Outer JoinMySQL Left Outer Join
 MySQL Right Outer JoinMySQL Right Outer Join
MySQL Left Outer JoinMySQL Left Outer Join
 Left outer joinLeft outer join produces a complete set of records produces a complete set of records
from Table A, with the matching records (wherefrom Table A, with the matching records (where
available) in Table B. If there is no match, the right sideavailable) in Table B. If there is no match, the right side
will contain null.will contain null.
MySQL Left Outer JoinMySQL Left Outer Join
 The left join is used in case of need to return all rowsThe left join is used in case of need to return all rows
from the left table, even if the right table doesn't havefrom the left table, even if the right table doesn't have
any match.any match.
 Example:Example:
 SELECT Persons.LastName,SELECT Persons.LastName,
Persons.FirstName, Orders.OrderNoPersons.FirstName, Orders.OrderNo
FROM Persons LEFT JOIN OrdersFROM Persons LEFT JOIN Orders
ON Persons.P_Id=Orders.P_IdON Persons.P_Id=Orders.P_Id
ORDER BY Persons.LastNameORDER BY Persons.LastName
(Contd:)
MySQL Right Outer JoinMySQL Right Outer Join
 The right join is used in case of need to return allThe right join is used in case of need to return all
rows from the right table, even if the left tablerows from the right table, even if the left table
doesn't have any match.doesn't have any match.
 Example:Example:
 SELECT Persons.LastName,Persons.FirstName,SELECT Persons.LastName,Persons.FirstName,
Orders.OrderNoOrders.OrderNo
FROM Persons RIGHT JOIN OrdersFROM Persons RIGHT JOIN Orders
ON Persons.P_Id = Orders.P_IdON Persons.P_Id = Orders.P_Id
ORDER BY Persons.LastNameORDER BY Persons.LastName
MySQL Cross JoinMySQL Cross Join
 Cross Join is also called Cartesian Product Join.Cross Join is also called Cartesian Product Join.
 The Cross Join in SQL return you  a result table inThe Cross Join in SQL return you  a result table in
which each row from the first table is combined withwhich each row from the first table is combined with
each rows from the second table.each rows from the second table.
MySQL Cross JoinMySQL Cross Join
 In other words, you can say it is the crossIn other words, you can say it is the cross
multiplication of number of rows in each table.multiplication of number of rows in each table. 
 Example:Example:
 SELECT * FROM persons cross join orders;SELECT * FROM persons cross join orders;
(Contd:)
MySQL Equi JoinMySQL Equi Join
 Equi Join is a classified type of Inner Join in Mysql.Equi Join is a classified type of Inner Join in Mysql.
 Equi Join is used to combine records from two tableEqui Join is used to combine records from two table
based on the common column exists in both table.based on the common column exists in both table.
 The Equi Join returns you only those records whichThe Equi Join returns you only those records which
are available in both table on the basis of commonare available in both table on the basis of common
primary field name.primary field name.
 Example:Example:
 SELECT persons.firstname,orders.orderNoSELECT persons.firstname,orders.orderNo
FROM persons, ordersFROM persons, orders
WHERE persons.p_id = orders.p_id;WHERE persons.p_id = orders.p_id;
MySQL Natural JoinMySQL Natural Join
 MySQL Natural Join is a specialization of equi-joins.MySQL Natural Join is a specialization of equi-joins.
 The join compares all columns in both tables thatThe join compares all columns in both tables that
have the same column-name in both tables that havehave the same column-name in both tables that have
column name in the joined table.column name in the joined table.
 Example:Example:
 SELECT persons.firstname, orders.orderNoSELECT persons.firstname, orders.orderNo
FROM persons NATURAL JOIN orders;FROM persons NATURAL JOIN orders;
MySQL Self JoinMySQL Self Join
 These join allow you to retrieve related recordsThese join allow you to retrieve related records
from the same table. from the same table. 
 The most common case where you'd use a self-join isThe most common case where you'd use a self-join is
when you have a table that references itself.when you have a table that references itself.
 Example:Example:
 SELECT m.name as "Manager", p.name asSELECT m.name as "Manager", p.name as
"Employee“"Employee“
FROM employee m, employee pFROM employee m, employee p
WHERE m.emp_id = p.manager_id;WHERE m.emp_id = p.manager_id;

More Related Content

PPT
Introduction to sql
VARSHAKUMARI49
 
PPT
Les08 (manipulating data)
Achmad Solichin
 
PPTX
AGGREGATE FUNCTION.pptx
Anusha sivakumar
 
PPTX
Triggers
Pooja Dixit
 
PPT
Manipulating Data Oracle Data base
Salman Memon
 
DOCX
Sql Queries
User1test
 
PDF
SQL Joins With Examples | Edureka
Edureka!
 
Introduction to sql
VARSHAKUMARI49
 
Les08 (manipulating data)
Achmad Solichin
 
AGGREGATE FUNCTION.pptx
Anusha sivakumar
 
Triggers
Pooja Dixit
 
Manipulating Data Oracle Data base
Salman Memon
 
Sql Queries
User1test
 
SQL Joins With Examples | Edureka
Edureka!
 

What's hot (20)

PPTX
Commands of DML in SQL
Ashish Gaurkhede
 
PPT
Aggregate functions
sinhacp
 
PPT
SQL subquery
Vikas Gupta
 
PPTX
Bsc cs ii dfs u-3 tree and graph
Rai University
 
PPT
05 Creating Stored Procedures
rehaniltifat
 
PPTX
NESTED SUBQUERY.pptx
Anusha sivakumar
 
PDF
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Balwant Gorad
 
PPTX
Sql Constraints
I L0V3 CODING DR
 
PPTX
SQL JOIN
Ritwik Das
 
PPTX
Sql joins
Gaurav Dhanwant
 
PDF
Alter table command
ravikhandelwal41
 
DOCX
Top 40 sql queries for testers
tlvd
 
PPTX
Sql commands
Pooja Dixit
 
PPTX
Joins And Its Types
Wings Interactive
 
PPT
Sql operators & functions 3
Dr. C.V. Suresh Babu
 
PPT
Sql query [select, sub] 4
Dr. C.V. Suresh Babu
 
PPT
Types Of Join In Sql Server - Join With Example In Sql Server
programmings guru
 
DOC
Sql queires
MohitKumar1985
 
PPTX
Lab2 ddl commands
Balqees Al.Mubarak
 
PPT
Advanced sql
Dhani Ahmad
 
Commands of DML in SQL
Ashish Gaurkhede
 
Aggregate functions
sinhacp
 
SQL subquery
Vikas Gupta
 
Bsc cs ii dfs u-3 tree and graph
Rai University
 
05 Creating Stored Procedures
rehaniltifat
 
NESTED SUBQUERY.pptx
Anusha sivakumar
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Balwant Gorad
 
Sql Constraints
I L0V3 CODING DR
 
SQL JOIN
Ritwik Das
 
Sql joins
Gaurav Dhanwant
 
Alter table command
ravikhandelwal41
 
Top 40 sql queries for testers
tlvd
 
Sql commands
Pooja Dixit
 
Joins And Its Types
Wings Interactive
 
Sql operators & functions 3
Dr. C.V. Suresh Babu
 
Sql query [select, sub] 4
Dr. C.V. Suresh Babu
 
Types Of Join In Sql Server - Join With Example In Sql Server
programmings guru
 
Sql queires
MohitKumar1985
 
Lab2 ddl commands
Balqees Al.Mubarak
 
Advanced sql
Dhani Ahmad
 
Ad

Viewers also liked (10)

PPTX
MySQL JOIN & UNION
Jamshid Hashimi
 
PPT
Relational+algebra (1)
Mathan Mathan K
 
ODP
Mysql count
Ritwik Das
 
PDF
Types of Error in PHP
Vineet Kumar Saini
 
PPTX
Database normalization
Jignesh Jain
 
PDF
Join-fu: The Art of SQL Tuning for MySQL
ZendCon
 
PDF
MySQL Query And Index Tuning
Manikanda kumar
 
PDF
程序猿都该知道的MySQL秘籍
Jinrong Ye
 
PPT
Lecture 06 relational algebra and calculus
emailharmeet
 
PPT
Entity relationship diagram (erd)
tameemyousaf
 
MySQL JOIN & UNION
Jamshid Hashimi
 
Relational+algebra (1)
Mathan Mathan K
 
Mysql count
Ritwik Das
 
Types of Error in PHP
Vineet Kumar Saini
 
Database normalization
Jignesh Jain
 
Join-fu: The Art of SQL Tuning for MySQL
ZendCon
 
MySQL Query And Index Tuning
Manikanda kumar
 
程序猿都该知道的MySQL秘籍
Jinrong Ye
 
Lecture 06 relational algebra and calculus
emailharmeet
 
Entity relationship diagram (erd)
tameemyousaf
 
Ad

Similar to PHP mysql Mysql joins (20)

PPT
Sql join
Vikas Gupta
 
PPTX
JOINS.pptx
ArunkumarT51
 
PPT
Join sql
Vikas Gupta
 
PPTX
joins and subqueries in big data analysis
SanSan149
 
PPTX
MergeResult_2024_02_09_08_59_11.pptx
KrishnansuSenapati
 
PPTX
SQL Server Joins.pptx the concept of joins in the oracle and mysql in dbms
narasimharaoPV1
 
PPTX
Kailas Manoj SQL Joins.pptxhgvhhhbjgjjjjjgjgjjj
kailasmanoj
 
PDF
Kailas Manoj SQL Joins.pdfhvhggjbhbbjbjbbjbj
kailasmanoj
 
PPTX
Lab4 join - all types listed
Balqees Al.Mubarak
 
PPTX
Sql slid
pacatarpit
 
PPT
Joins.ppt
UmangThakkar26
 
PDF
3)12th_L8_Join-Set-Operations.pdf
AdityavardhanSingh15
 
DOCX
SQL report
Ahmad Zahid
 
PPTX
Structured Query Language (SQL)
Hammad Rasheed
 
PPTX
SQL Basics
Hammad Rasheed
 
PPTX
Join in SQL - Inner, Self, Outer Join
Souma Maiti
 
PPTX
Joins in SQL
Pooja Dixit
 
PPTX
Lesson 2_Working_with_Tables_and_SQL_Commands.pptx
quantumlearnai
 
PPTX
DBMS and SQL(structured query language) .pptx
jainendraKUMAR55
 
Sql join
Vikas Gupta
 
JOINS.pptx
ArunkumarT51
 
Join sql
Vikas Gupta
 
joins and subqueries in big data analysis
SanSan149
 
MergeResult_2024_02_09_08_59_11.pptx
KrishnansuSenapati
 
SQL Server Joins.pptx the concept of joins in the oracle and mysql in dbms
narasimharaoPV1
 
Kailas Manoj SQL Joins.pptxhgvhhhbjgjjjjjgjgjjj
kailasmanoj
 
Kailas Manoj SQL Joins.pdfhvhggjbhbbjbjbbjbj
kailasmanoj
 
Lab4 join - all types listed
Balqees Al.Mubarak
 
Sql slid
pacatarpit
 
Joins.ppt
UmangThakkar26
 
3)12th_L8_Join-Set-Operations.pdf
AdityavardhanSingh15
 
SQL report
Ahmad Zahid
 
Structured Query Language (SQL)
Hammad Rasheed
 
SQL Basics
Hammad Rasheed
 
Join in SQL - Inner, Self, Outer Join
Souma Maiti
 
Joins in SQL
Pooja Dixit
 
Lesson 2_Working_with_Tables_and_SQL_Commands.pptx
quantumlearnai
 
DBMS and SQL(structured query language) .pptx
jainendraKUMAR55
 

More from Mudasir Syed (20)

PPT
Error reporting in php
Mudasir Syed
 
PPT
Cookies in php lecture 2
Mudasir Syed
 
PPT
Cookies in php lecture 1
Mudasir Syed
 
PPTX
Ajax
Mudasir Syed
 
PPT
Reporting using FPDF
Mudasir Syed
 
PPT
Oop in php lecture 2
Mudasir Syed
 
PPT
Oop in php lecture 2
Mudasir Syed
 
PPT
Filing system in PHP
Mudasir Syed
 
PPT
Time manipulation lecture 2
Mudasir Syed
 
PPT
Time manipulation lecture 1
Mudasir Syed
 
PPT
Php Mysql
Mudasir Syed
 
PPT
Adminstrating Through PHPMyAdmin
Mudasir Syed
 
PPT
Sql select
Mudasir Syed
 
PPT
PHP mysql Sql
Mudasir Syed
 
PPTX
PHP mysql Introduction database
Mudasir Syed
 
PPT
PHP mysql Installing my sql 5.1
Mudasir Syed
 
PPT
PHP mysql Er diagram
Mudasir Syed
 
PPT
PHP mysql Database normalizatin
Mudasir Syed
 
PPT
PHP mysql Aggregate functions
Mudasir Syed
 
PPT
Form validation with built in functions
Mudasir Syed
 
Error reporting in php
Mudasir Syed
 
Cookies in php lecture 2
Mudasir Syed
 
Cookies in php lecture 1
Mudasir Syed
 
Reporting using FPDF
Mudasir Syed
 
Oop in php lecture 2
Mudasir Syed
 
Oop in php lecture 2
Mudasir Syed
 
Filing system in PHP
Mudasir Syed
 
Time manipulation lecture 2
Mudasir Syed
 
Time manipulation lecture 1
Mudasir Syed
 
Php Mysql
Mudasir Syed
 
Adminstrating Through PHPMyAdmin
Mudasir Syed
 
Sql select
Mudasir Syed
 
PHP mysql Sql
Mudasir Syed
 
PHP mysql Introduction database
Mudasir Syed
 
PHP mysql Installing my sql 5.1
Mudasir Syed
 
PHP mysql Er diagram
Mudasir Syed
 
PHP mysql Database normalizatin
Mudasir Syed
 
PHP mysql Aggregate functions
Mudasir Syed
 
Form validation with built in functions
Mudasir Syed
 

Recently uploaded (20)

PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PPTX
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 

PHP mysql Mysql joins

  • 2. MySQL Joins OverviewMySQL Joins Overview  MySQL Join is used to join the records from twoMySQL Join is used to join the records from two tables using join clause.tables using join clause.  The Join Clause return you the set of records fromThe Join Clause return you the set of records from both table on the basis of common column.both table on the basis of common column.
  • 3. MySQL Join TypesMySQL Join Types  MySQLMySQL Inner JoinInner Join  MySQL Equi JoinMySQL Equi Join  MySQL Natural JoinMySQL Natural Join  MySQL Cross JoinMySQL Cross Join  MySQL Outer JoinMySQL Outer Join  Left Outer JoinLeft Outer Join  Right Outer JoinRight Outer Join  Self JoinSelf Join
  • 4.  Inner joinInner join produces only the set of records that produces only the set of records that match in both Table A and Table B.match in both Table A and Table B. MySQL Inner JoinMySQL Inner Join
  • 5.  The INNER JOIN keyword returns rows when thereThe INNER JOIN keyword returns rows when there is at least one match in both tables.is at least one match in both tables.  If there are rows in "Persons" that do not haveIf there are rows in "Persons" that do not have matches in "Orders", those rows will NOT be listed.matches in "Orders", those rows will NOT be listed.  Example:Example:  SELECT Persons.LastName,SELECT Persons.LastName, Persons.FirstName, Orders.OrderNoPersons.FirstName, Orders.OrderNo FROM Persons INNER JOIN OrdersFROM Persons INNER JOIN Orders ON Persons.P_Id = Orders.P_IdON Persons.P_Id = Orders.P_Id ORDER BY Persons.LastNameORDER BY Persons.LastName (Contd:)MySQL Inner JoinMySQL Inner Join
  • 6. MySQL Outer JoinMySQL Outer Join  MySQL Outer Join return you the set of all matchingMySQL Outer Join return you the set of all matching records from both table.records from both table.  The Outer Join does not requires each records to beThe Outer Join does not requires each records to be matched in both the tables.matched in both the tables.  MySQL Outer Join is categorized into two groups.MySQL Outer Join is categorized into two groups.  MySQL Left Outer JoinMySQL Left Outer Join  MySQL Right Outer JoinMySQL Right Outer Join
  • 7. MySQL Left Outer JoinMySQL Left Outer Join  Left outer joinLeft outer join produces a complete set of records produces a complete set of records from Table A, with the matching records (wherefrom Table A, with the matching records (where available) in Table B. If there is no match, the right sideavailable) in Table B. If there is no match, the right side will contain null.will contain null.
  • 8. MySQL Left Outer JoinMySQL Left Outer Join  The left join is used in case of need to return all rowsThe left join is used in case of need to return all rows from the left table, even if the right table doesn't havefrom the left table, even if the right table doesn't have any match.any match.  Example:Example:  SELECT Persons.LastName,SELECT Persons.LastName, Persons.FirstName, Orders.OrderNoPersons.FirstName, Orders.OrderNo FROM Persons LEFT JOIN OrdersFROM Persons LEFT JOIN Orders ON Persons.P_Id=Orders.P_IdON Persons.P_Id=Orders.P_Id ORDER BY Persons.LastNameORDER BY Persons.LastName (Contd:)
  • 9. MySQL Right Outer JoinMySQL Right Outer Join  The right join is used in case of need to return allThe right join is used in case of need to return all rows from the right table, even if the left tablerows from the right table, even if the left table doesn't have any match.doesn't have any match.  Example:Example:  SELECT Persons.LastName,Persons.FirstName,SELECT Persons.LastName,Persons.FirstName, Orders.OrderNoOrders.OrderNo FROM Persons RIGHT JOIN OrdersFROM Persons RIGHT JOIN Orders ON Persons.P_Id = Orders.P_IdON Persons.P_Id = Orders.P_Id ORDER BY Persons.LastNameORDER BY Persons.LastName
  • 10. MySQL Cross JoinMySQL Cross Join  Cross Join is also called Cartesian Product Join.Cross Join is also called Cartesian Product Join.  The Cross Join in SQL return you  a result table inThe Cross Join in SQL return you  a result table in which each row from the first table is combined withwhich each row from the first table is combined with each rows from the second table.each rows from the second table.
  • 11. MySQL Cross JoinMySQL Cross Join  In other words, you can say it is the crossIn other words, you can say it is the cross multiplication of number of rows in each table.multiplication of number of rows in each table.   Example:Example:  SELECT * FROM persons cross join orders;SELECT * FROM persons cross join orders; (Contd:)
  • 12. MySQL Equi JoinMySQL Equi Join  Equi Join is a classified type of Inner Join in Mysql.Equi Join is a classified type of Inner Join in Mysql.  Equi Join is used to combine records from two tableEqui Join is used to combine records from two table based on the common column exists in both table.based on the common column exists in both table.  The Equi Join returns you only those records whichThe Equi Join returns you only those records which are available in both table on the basis of commonare available in both table on the basis of common primary field name.primary field name.  Example:Example:  SELECT persons.firstname,orders.orderNoSELECT persons.firstname,orders.orderNo FROM persons, ordersFROM persons, orders WHERE persons.p_id = orders.p_id;WHERE persons.p_id = orders.p_id;
  • 13. MySQL Natural JoinMySQL Natural Join  MySQL Natural Join is a specialization of equi-joins.MySQL Natural Join is a specialization of equi-joins.  The join compares all columns in both tables thatThe join compares all columns in both tables that have the same column-name in both tables that havehave the same column-name in both tables that have column name in the joined table.column name in the joined table.  Example:Example:  SELECT persons.firstname, orders.orderNoSELECT persons.firstname, orders.orderNo FROM persons NATURAL JOIN orders;FROM persons NATURAL JOIN orders;
  • 14. MySQL Self JoinMySQL Self Join  These join allow you to retrieve related recordsThese join allow you to retrieve related records from the same table. from the same table.   The most common case where you'd use a self-join isThe most common case where you'd use a self-join is when you have a table that references itself.when you have a table that references itself.  Example:Example:  SELECT m.name as "Manager", p.name asSELECT m.name as "Manager", p.name as "Employee“"Employee“ FROM employee m, employee pFROM employee m, employee p WHERE m.emp_id = p.manager_id;WHERE m.emp_id = p.manager_id;