SlideShare a Scribd company logo
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

What's hot (20)

SQL Views
SQL ViewsSQL Views
SQL Views
baabtra.com - No. 1 supplier of quality freshers
 
Joins And Its Types
Joins And Its TypesJoins And Its Types
Joins And Its Types
Wings Interactive
 
Top 40 sql queries for testers
Top 40 sql queries for testersTop 40 sql queries for testers
Top 40 sql queries for testers
tlvd
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
Bwsrang Basumatary
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
Balqees Al.Mubarak
 
SQL Joins With Examples | Edureka
SQL Joins With Examples | EdurekaSQL Joins With Examples | Edureka
SQL Joins With Examples | Edureka
Edureka!
 
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
programmings guru
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
Md.Mojibul Hoque
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
Dhananjay Goel
 
Html
HtmlHtml
Html
Lakshmy TM
 
Triggers and Stored Procedures
Triggers and Stored ProceduresTriggers and Stored Procedures
Triggers and Stored Procedures
Tharindu Weerasinghe
 
Sql clauses by Manan Pasricha
Sql clauses by Manan PasrichaSql clauses by Manan Pasricha
Sql clauses by Manan Pasricha
MananPasricha
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
V.V.Vanniaperumal College for Women
 
Workshop 21: React Router
Workshop 21: React RouterWorkshop 21: React Router
Workshop 21: React Router
Visual Engineering
 
Bootcamp sql fundamental
Bootcamp sql fundamentalBootcamp sql fundamental
Bootcamp sql fundamental
varunbhatt23
 
Exception handling in plsql
Exception handling in plsqlException handling in plsql
Exception handling in plsql
Arun Sial
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
farwa waqar
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
Pongsakorn U-chupala
 
Mysql joins
Mysql joinsMysql joins
Mysql joins
baabtra.com - No. 1 supplier of quality freshers
 
Bootstrap PPT Part - 2
Bootstrap PPT Part - 2Bootstrap PPT Part - 2
Bootstrap PPT Part - 2
EPAM Systems
 

Viewers also liked (10)

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

Similar to PHP mysql Mysql joins (20)

MySQL JOINS
MySQL JOINSMySQL JOINS
MySQL JOINS
HripsimeGhaltaghchya
 
MYSQL join
MYSQL joinMYSQL join
MYSQL join
Ahmed Farag
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
PuNeEt KuMaR
 
SQL Join's
SQL Join'sSQL Join's
SQL Join's
Muhammad Noman Fazil
 
V19 join method-c
V19 join method-cV19 join method-c
V19 join method-c
Dhirendra Chauhan
 
Join query
Join queryJoin query
Join query
Waqar Ali
 
sql joins.pptx
sql joins.pptxsql joins.pptx
sql joins.pptx
HFHJJHC
 
Tipos de Joins para consultas em banco de dados.pdf
Tipos de Joins para consultas em banco de dados.pdfTipos de Joins para consultas em banco de dados.pdf
Tipos de Joins para consultas em banco de dados.pdf
PabloLpez168453
 
SQL joins for Database Testing easy .pdf
SQL joins for Database Testing easy .pdfSQL joins for Database Testing easy .pdf
SQL joins for Database Testing easy .pdf
RohitSharma189763
 
SQL JOIN
SQL JOINSQL JOIN
SQL JOIN
Ritwik Das
 
Joins and unions
Joins and unionsJoins and unions
Joins and unions
baabtra.com - No. 1 supplier of quality freshers
 
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrksql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
kailasmanoj
 
sqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwf
sqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwfsqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwf
sqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwf
kailasmanoj
 
Joins and unions
Joins and unionsJoins and unions
Joins and unions
baabtra.com - No. 1 supplier of quality freshers
 
Joins SQL Server
Joins SQL ServerJoins SQL Server
Joins SQL Server
baabtra.com - No. 1 supplier of quality freshers
 
DBMS: Week 08 - Joins and Views in MySQL
DBMS: Week 08 - Joins and Views in MySQLDBMS: Week 08 - Joins and Views in MySQL
DBMS: Week 08 - Joins and Views in MySQL
RashidFaridChishti
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
Joshi Vinay
 
SQL JOINS.pdf
SQL JOINS.pdfSQL JOINS.pdf
SQL JOINS.pdf
fariaafrin11
 
SQL Joins.pdf
SQL Joins.pdfSQL Joins.pdf
SQL Joins.pdf
NiravPanchal50
 
SQL_Joins.pdf
SQL_Joins.pdfSQL_Joins.pdf
SQL_Joins.pdf
ssuser9ed5e31
 
Ad

More from Mudasir Syed (20)

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

Recently uploaded (20)

Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
Quiz Club of PSG College of Arts & Science
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti MpdBasic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptxPests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Arshad Shaikh
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
Pfeiffer "Secrets to Changing Behavior in Scholarly Communication: A 2025 NIS...
National Information Standards Organization (NISO)
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti MpdBasic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptxPests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Arshad Shaikh
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 

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;