An introduction to SQL Joins

  • Inner Join
  • Left Join
  • Right Join
  • Full Outer Join
  • Cross Join
  • Self Join
customer table
transactions table
Inner Join
SELECT *
FROM Customers
INNER JOIN Transactions
ON CUSTOMER.customer_id = Transactions.customer_id
Left Join
SELECT *
FROM Customers c
LEFT JOIN Transactions t
ON c.customer_id = t.customer_id;
Right Join
SELECT *
FROM Customer c
RIGHT JOIN Transactions t
ON c.customer_id = t.customer_id;
Full outer Join
SELECT *
FROM Customer
FULL OUTER JOIN Transactions;
SELECT columns_list
FROM table1 t1
INNER JOIN table1 t2
ON t1.column_name = t2.column_name;
SELECT Column_name
FROM Table_1 t1
CROSS JOIN Table_2 t2;

Explicit Join vs Implicit Join

SELECT column_names
FROM table_1
JOIN table_2
ON table_1.common_key = table_2.common_key;
SELECT column_name
FROM table_1, table_2, table_3
WHERE table_1.common_key = table_2.common_key
AND table_2.common_key = table_3.common_key;
SELECT *
FROM table_1
UNION
SELECT *
FROM table_2;

--

--

--

Data Analyst | BI Analyst | Tableau Expert.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Distributed transaction boundaries and microservices

It’s a-MAZE-ing!

Agile Manifesto

GraalVM 21.0 VS Code Extensions Released

A Pulse Oximeter Device using Arduino Nano, MAX30100 Sensor and Bluetooth HC06

Atlassian Summit 2019: the news report by Deviniti

Is There Any Tool For Converting Text To Speech Using PHP?

Introduction to the Basics of Python 3-Part 12

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yomisola Adegeye

Yomisola Adegeye

Data Analyst | BI Analyst | Tableau Expert.

More from Medium

SQL Exercises 8 — Subqueries

How to find second highest salary in SQL Using Max function

Somewhat complex reporting and data analysis in MySql 8 — Part 1