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

RT-Thread Community Report in May 2020

Kubernetes and Secrets Management in Cloud

Serving 7 million users more efficient images on Bethesda.net

CS371p Spring 2019: Final Entry

FXCE’s EA Future Testing Program

One Day In The Life Of A Student Developer In Kenya

Vaccine Slot Notifier using AWS & Python

Learn PHP The Right Way Part 1

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

COALESCE function in SQL

#100DaysofSQL | DAY 12:

INTRODUCTION TO SQL

SQL Practices with Real Cases — 1