SlideShare a Scribd company logo
Prepared by
Aftab Alam
Ashfaq Ahmad
Waqar Ali
Join Query
What is Join Query?
• Join is used to combine records from two
or more tables in a database.
• In database Join means combining fields
from two tables by using values common
to each.
• The data which is fetch from two or more
tables, is appear as single set of data.
Syntax
• Simple Join Query :
SELECT ColumnName_list from table1,table2
WHERE
table1.col = table2.col;
But it is old version.
• Simple join is also called inner join. but the syntax of inner join is
different, Both work same as simple query does.
SELECT ColumnName_list from table1
INNER JOIN
table2 ON table1.col = table2.col;
• It is also recommended syntax by Oracle.
Example
• Consider two tables CUSTOMER and ORDER
• CUSTOMER
In customer table we have three columns.
Customer_id
name
age.
• ORDER
In ORDER table we have
order_id
order_date
customer_id
amount number
• customer_id is common in both tables. And also we can use it for
relationship between these two tables.
Customer and Order tables
• In customer table we have following data
• In orders table we have following data
Joining tables
To joining the previous two tables
• We use the following queries:
Old:
select order_id, name, order_date, amount
from customer, orders
WHERE
customer.customer_id = orders.customer_id;
Recommend:
select order_id, name, order_date, amount
from customer
INNER JOIN orders on
customer.customer_id = orders.customer_id;
Types of Join Query
1.Inner Join
2.Left Join
3.Right Join
4.Full Join
There are also more types of join
but we will discuss only the above
types
Inner Join
• It selects all rows from both tables when
there is a columns and its values match
between two tables.
• In other words it returns rows when
there is a match in both tables.
Syntax:
SELECT column_name(s)
FROM table1
INNER JOIN table2 ON
table1.column_name=table2.column_name;
Inner Join Example
• Query
Select * from customer
inner join orders on
customer.customer_id = orders.customer_id;
Left Join
• It returns all rows from the left table (table1),
with the matching rows in the right table
(table2). The result is NULL in the right side
when there is no match.
• In other words it returns all rows from the left
table, even if there are no matches in the
right table.
Syntax:
SELECT column_name(s)
FROM table1
LEFT JOIN table2 ON
table1.column_name=table2.column_name;
Left Join Example
• Query
Select * from customer
left join orders on
customer.customer_id = orders.customer_id;
Right Join
• The RIGHT JOIN keyword returns all rows
from the right table (table2), with the
matching rows in the left table (table1). The
result is NULL in the left side when there is no
match.
• In other words returns all rows from the right
table, even if there are no matches in the left
table.
Syntax:
SELECT column_name(s)
FROM table1
RIGHT JOIN table2 ON
table1.column_name=table2.column_name;
Right Join Example
• Query
Select * from customer
right join orders on
customer.customer_id = orders.customer_id;
Full Join
• It combines the results of both left and right
table.
• The joined table will contain all records from
both tables, and fill in NULLs for missing
matches on either side.
Syntax:
SELECT column_name(s)
FROM table1
FULL JOIN table2 ON
table1.column_name=table2.column_name;
Full Join Example
• Query
Select * from customer
full join orders on
customer.customer_id = orders.customer_id;

More Related Content

What's hot

Sql join
Sql  joinSql  join
Sql join
Vikas Gupta
 
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: Joining Databases
MS Sql Server: Joining DatabasesMS Sql Server: Joining Databases
MS Sql Server: Joining Databases
DataminingTools Inc
 
joins and subqueries in big data analysis
joins and subqueries in big data analysisjoins and subqueries in big data analysis
joins and subqueries in big data analysis
SanSan149
 
Join
JoinJoin
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
Swapnali Pawar
 
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
SomeshwarMoholkar
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
Raveena Thakur
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
Ishucs
 
Sql joins
Sql joinsSql joins
Sql joins
Gaurav Dhanwant
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
Punjab University
 
joins in database
 joins in database joins in database
joins in database
Sultan Arshad
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer joinNargis Ehsan
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
Stewart Rogers
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
Balqees Al.Mubarak
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
Felipe Costa
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
Nilt1234
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
Syed Zaid Irshad
 

What's hot (20)

Sql join
Sql  joinSql  join
Sql join
 
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
 
Mysql
MysqlMysql
Mysql
 
MS Sql Server: Joining Databases
MS Sql Server: Joining DatabasesMS Sql Server: Joining Databases
MS Sql Server: Joining Databases
 
joins and subqueries in big data analysis
joins and subqueries in big data analysisjoins and subqueries in big data analysis
joins and subqueries in big data analysis
 
Join
JoinJoin
Join
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
 
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
 
Sql joins
Sql joinsSql joins
Sql joins
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
 
joins in database
 joins in database joins in database
joins in database
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer join
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 

Viewers also liked

What is Martial Arts ?
What is Martial Arts ?What is Martial Arts ?
What is Martial Arts ?
The Movie Ninjas
 
Important table
Important table Important table
Important table
Aman Ullah
 
Solar Roadways
Solar RoadwaysSolar Roadways
Solar Roadways
Shreyashkar Singh
 
Hardware without Hardware, minimal explorations of novel product ideas (O'Rei...
Hardware without Hardware, minimal explorations of novel product ideas (O'Rei...Hardware without Hardware, minimal explorations of novel product ideas (O'Rei...
Hardware without Hardware, minimal explorations of novel product ideas (O'Rei...
Mike Kuniavsky
 
Enterprise Fraud Management - Challenges Brings New Opportunities
Enterprise Fraud Management - Challenges Brings New OpportunitiesEnterprise Fraud Management - Challenges Brings New Opportunities
Enterprise Fraud Management - Challenges Brings New Opportunities
cVidya Networks
 
Wireless sensor networks
Wireless sensor networksWireless sensor networks
Wireless sensor networks
studying telecommuciation engineering
 
Identification of pathogenic bacteria in clinical microbiology
Identification of pathogenic bacteria in clinical microbiologyIdentification of pathogenic bacteria in clinical microbiology
Identification of pathogenic bacteria in clinical microbiology
Aman Ullah
 
Biochemical tests (1st part)
Biochemical tests (1st part)Biochemical tests (1st part)
Biochemical tests (1st part)
Aman Ullah
 
Software Testing and Debugging
Software Testing and DebuggingSoftware Testing and Debugging
Software Testing and Debugging
university of education,Lahore
 
Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)
Oum Saokosal
 
E. histolytica
E. histolyticaE. histolytica
E. histolytica
Umar Farooq Gaur
 
Pmkvy 2.0 guidelines (2016 2020)
Pmkvy 2.0 guidelines (2016 2020)Pmkvy 2.0 guidelines (2016 2020)
Pmkvy 2.0 guidelines (2016 2020)
SUNAINA SAMRIDDHI FOUNDATION
 
Blood component & its QC
Blood component & its QCBlood component & its QC
Blood component & its QC
Asif Zeb
 
Practical Advice on Bringing Foreign National Employees to Work in the U.S.
Practical Advice on Bringing Foreign National Employees to Work in the U.S.Practical Advice on Bringing Foreign National Employees to Work in the U.S.
Practical Advice on Bringing Foreign National Employees to Work in the U.S.
Quarles & Brady
 
A Sea Change in Wage and Hour Law
A Sea Change in Wage and Hour LawA Sea Change in Wage and Hour Law
A Sea Change in Wage and Hour Law
Quarles & Brady
 
Classification of parasites
Classification of parasitesClassification of parasites
Classification of parasites
Aman Ullah
 

Viewers also liked (17)

What is Martial Arts ?
What is Martial Arts ?What is Martial Arts ?
What is Martial Arts ?
 
Important table
Important table Important table
Important table
 
Solar Roadways
Solar RoadwaysSolar Roadways
Solar Roadways
 
Hardware without Hardware, minimal explorations of novel product ideas (O'Rei...
Hardware without Hardware, minimal explorations of novel product ideas (O'Rei...Hardware without Hardware, minimal explorations of novel product ideas (O'Rei...
Hardware without Hardware, minimal explorations of novel product ideas (O'Rei...
 
Enterprise Fraud Management - Challenges Brings New Opportunities
Enterprise Fraud Management - Challenges Brings New OpportunitiesEnterprise Fraud Management - Challenges Brings New Opportunities
Enterprise Fraud Management - Challenges Brings New Opportunities
 
Wireless sensor networks
Wireless sensor networksWireless sensor networks
Wireless sensor networks
 
Identification of pathogenic bacteria in clinical microbiology
Identification of pathogenic bacteria in clinical microbiologyIdentification of pathogenic bacteria in clinical microbiology
Identification of pathogenic bacteria in clinical microbiology
 
Biochemical tests (1st part)
Biochemical tests (1st part)Biochemical tests (1st part)
Biochemical tests (1st part)
 
Software Testing and Debugging
Software Testing and DebuggingSoftware Testing and Debugging
Software Testing and Debugging
 
Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)Database Concept - Normalization (1NF, 2NF, 3NF)
Database Concept - Normalization (1NF, 2NF, 3NF)
 
E. histolytica
E. histolyticaE. histolytica
E. histolytica
 
Pmkvy 2.0 guidelines (2016 2020)
Pmkvy 2.0 guidelines (2016 2020)Pmkvy 2.0 guidelines (2016 2020)
Pmkvy 2.0 guidelines (2016 2020)
 
CV THOA 03.2014
CV THOA 03.2014CV THOA 03.2014
CV THOA 03.2014
 
Blood component & its QC
Blood component & its QCBlood component & its QC
Blood component & its QC
 
Practical Advice on Bringing Foreign National Employees to Work in the U.S.
Practical Advice on Bringing Foreign National Employees to Work in the U.S.Practical Advice on Bringing Foreign National Employees to Work in the U.S.
Practical Advice on Bringing Foreign National Employees to Work in the U.S.
 
A Sea Change in Wage and Hour Law
A Sea Change in Wage and Hour LawA Sea Change in Wage and Hour Law
A Sea Change in Wage and Hour Law
 
Classification of parasites
Classification of parasitesClassification of parasites
Classification of parasites
 

Similar to Join query

Joins and Views.pptx
Joins and Views.pptxJoins and Views.pptx
Joins and Views.pptx
SangitaKabi
 
SQL JOIN.pptx
SQL JOIN.pptxSQL JOIN.pptx
SQL JOIN.pptx
johnwick814916
 
Sql joins final
Sql joins finalSql joins final
Sql joins final
mbadhi
 
Sql
SqlSql
MYSQL join
MYSQL joinMYSQL join
MYSQL join
Ahmed Farag
 
SQL Join's
SQL Join'sSQL Join's
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
PuNeEt KuMaR
 
JOINS.pptx
JOINS.pptxJOINS.pptx
JOINS.pptx
ArunkumarT51
 
Advance database system(part 8)
Advance database system(part 8)Advance database system(part 8)
Advance database system(part 8)
Abdullah Khosa
 
SQL Joins and View.pptx
SQL Joins and View.pptxSQL Joins and View.pptx
SQL Joins and View.pptx
pallavipatil634279
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
Priyabrat Kar
 
Joining
JoiningJoining
Joining
Abrar ali
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
Pooja Dixit
 
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
Souma Maiti
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
TechandMate
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptx
SherinRappai
 
Lesson 6 - Relational Algebra.pdf
Lesson 6 - Relational Algebra.pdfLesson 6 - Relational Algebra.pdf
Lesson 6 - Relational Algebra.pdf
HasankaWijesinghe1
 

Similar to Join query (20)

Joins and Views.pptx
Joins and Views.pptxJoins and Views.pptx
Joins and Views.pptx
 
SQL JOIN.pptx
SQL JOIN.pptxSQL JOIN.pptx
SQL JOIN.pptx
 
Sql joins final
Sql joins finalSql joins final
Sql joins final
 
Joins SQL Server
Joins SQL ServerJoins SQL Server
Joins SQL Server
 
Sql
SqlSql
Sql
 
MYSQL join
MYSQL joinMYSQL join
MYSQL join
 
SQL Join's
SQL Join'sSQL Join's
SQL Join's
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
 
JOINS.pptx
JOINS.pptxJOINS.pptx
JOINS.pptx
 
Advance database system(part 8)
Advance database system(part 8)Advance database system(part 8)
Advance database system(part 8)
 
SQL Joins and View.pptx
SQL Joins and View.pptxSQL Joins and View.pptx
SQL Joins and View.pptx
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
 
Joins and unions
Joins and unionsJoins and unions
Joins and unions
 
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
 
V19 join method-c
V19 join method-cV19 join method-c
V19 join method-c
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptx
 
Lesson 6 - Relational Algebra.pdf
Lesson 6 - Relational Algebra.pdfLesson 6 - Relational Algebra.pdf
Lesson 6 - Relational Algebra.pdf
 

More from Waqar Ali

Debugging by induction
Debugging by inductionDebugging by induction
Debugging by induction
Waqar Ali
 
Chapter 1 - Introduction
Chapter 1 - IntroductionChapter 1 - Introduction
Chapter 1 - Introduction
Waqar Ali
 
Project Time Management
Project Time Management Project Time Management
Project Time Management
Waqar Ali
 
Normalization
NormalizationNormalization
Normalization
Waqar Ali
 
Normalization
NormalizationNormalization
Normalization
Waqar Ali
 
The Ethical and Social Enviroment
The Ethical and Social EnviromentThe Ethical and Social Enviroment
The Ethical and Social Enviroment
Waqar Ali
 
File Handling
File HandlingFile Handling
File Handling
Waqar Ali
 

More from Waqar Ali (7)

Debugging by induction
Debugging by inductionDebugging by induction
Debugging by induction
 
Chapter 1 - Introduction
Chapter 1 - IntroductionChapter 1 - Introduction
Chapter 1 - Introduction
 
Project Time Management
Project Time Management Project Time Management
Project Time Management
 
Normalization
NormalizationNormalization
Normalization
 
Normalization
NormalizationNormalization
Normalization
 
The Ethical and Social Enviroment
The Ethical and Social EnviromentThe Ethical and Social Enviroment
The Ethical and Social Enviroment
 
File Handling
File HandlingFile Handling
File Handling
 

Recently uploaded

Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 

Recently uploaded (20)

Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 

Join query

  • 1. Prepared by Aftab Alam Ashfaq Ahmad Waqar Ali Join Query
  • 2. What is Join Query? • Join is used to combine records from two or more tables in a database. • In database Join means combining fields from two tables by using values common to each. • The data which is fetch from two or more tables, is appear as single set of data.
  • 3. Syntax • Simple Join Query : SELECT ColumnName_list from table1,table2 WHERE table1.col = table2.col; But it is old version. • Simple join is also called inner join. but the syntax of inner join is different, Both work same as simple query does. SELECT ColumnName_list from table1 INNER JOIN table2 ON table1.col = table2.col; • It is also recommended syntax by Oracle.
  • 4. Example • Consider two tables CUSTOMER and ORDER • CUSTOMER In customer table we have three columns. Customer_id name age. • ORDER In ORDER table we have order_id order_date customer_id amount number • customer_id is common in both tables. And also we can use it for relationship between these two tables.
  • 5. Customer and Order tables • In customer table we have following data • In orders table we have following data
  • 6. Joining tables To joining the previous two tables • We use the following queries: Old: select order_id, name, order_date, amount from customer, orders WHERE customer.customer_id = orders.customer_id; Recommend: select order_id, name, order_date, amount from customer INNER JOIN orders on customer.customer_id = orders.customer_id;
  • 7. Types of Join Query 1.Inner Join 2.Left Join 3.Right Join 4.Full Join There are also more types of join but we will discuss only the above types
  • 8. Inner Join • It selects all rows from both tables when there is a columns and its values match between two tables. • In other words it returns rows when there is a match in both tables. Syntax: SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name=table2.column_name;
  • 9. Inner Join Example • Query Select * from customer inner join orders on customer.customer_id = orders.customer_id;
  • 10. Left Join • It returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match. • In other words it returns all rows from the left table, even if there are no matches in the right table. Syntax: SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name=table2.column_name;
  • 11. Left Join Example • Query Select * from customer left join orders on customer.customer_id = orders.customer_id;
  • 12. Right Join • The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the left table (table1). The result is NULL in the left side when there is no match. • In other words returns all rows from the right table, even if there are no matches in the left table. Syntax: SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name=table2.column_name;
  • 13. Right Join Example • Query Select * from customer right join orders on customer.customer_id = orders.customer_id;
  • 14. Full Join • It combines the results of both left and right table. • The joined table will contain all records from both tables, and fill in NULLs for missing matches on either side. Syntax: SELECT column_name(s) FROM table1 FULL JOIN table2 ON table1.column_name=table2.column_name;
  • 15. Full Join Example • Query Select * from customer full join orders on customer.customer_id = orders.customer_id;