SQL Joins Query
SQL Joins Query
SQL Joins
For Data Analysis
Moaz Agha
01
Inner Join
The INNER JOIN is the most commonly
used join in SQL. It returns only the rows
that have matching values in both tables.
02
Left Join
The LEFT JOIN returns all rows from the
left table and the matching rows from the
right table. If there's no match in the right
table, it returns NULL values for the right
table columns.
03
Right Join
The RIGHT JOIN is the opposite of the LEFT
JOIN. It returns all rows from the right table
and the matching rows from the left table. If
there's no match in the left table, it returns
NULL values for the left table columns.
04
Full Outer Join
The FULL OUTER JOIN returns all rows from
both tables, matching rows from both tables,
and NULL values for non-matching rows.
05
Cross Join
The CROSS JOIN returns the Cartesian
product of both tables, which means it
returns all possible combinations of rows
between the two tables.
06
Self Join
A self join is a regular join, but the table is
joined with itself. It's often used to compare
data within the same table.
Table A
Using Joins 07
with Subqueries
Joins can be used with subqueries to filter data
further. In this example, we'll use a subquery to
get the maximum salary for each department,
and then join that with the employees table to
get the employees with that salary.
SQL joins are powerful tools for
working with data across
multiple tables.
This guide provides a solid
foundation to tackle various join
scenarios, but there are always
new challenges to explore.
I am
Moaz Agha
Dont forget to like, share
and save if you like this post