Description

The SQL keyword INNER JOIN is used to join two tables, which returns the rows having a match between the joined tables.

  • It is the most commonly used type of join.
  • It can be implemented on SELECT, UPDATE, and DELETE statements.
  • The table joins can be created using the WHERE clause by comparing the related columns between the joined tables.

INNER JOIN

The below SQL statement fetches data from specific columns of two tables, joined using INNER JOIN.

Run this on IDE

SELECT order_id, order_date, order_value, customer_name
FROM orders
INNER JOIN customers ON orders.customer_id = customers.customer_id;

INNER JOIN All Columns

The below SQL statement fetches data from all columns of two tables, joined using INNER JOIN.

Run this on IDE

SELECT *
FROM orders
INNER JOIN customers ON orders.customer_id = customers.customer_id;

INNER JOIN More Tables

The below SQL statement fetches data from more than two tables, joined using INNER JOIN.

Run this on IDE

SELECT order_id, order_date, order_value, customer_name, shipper_name
FROM orders
INNER JOIN customers ON orders.customer_id = customers.customer_id
INNER JOIN shippers ON orders.shipper_id = shippers.shipper_id;

Related Links