What is INNER JOIN ( Also Called As “Simple Join”) in MySQL?

 It returns all the rows for which there is at least one match in BOTH the tables. If join type is not specifically mentioned then “INNER JOIN” works as the default join.

INNER JOIN Syntax

SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;

Example of INNER JOIN

Customer Table

+------------+--------------+------------+------------+--------+------------+-----------+
| CustomerID | CustomerName | ContactNo  | Address    | CityID | PostalCode | CountryID |
+------------+--------------+------------+------------+--------+------------+-----------+
|          1 | Tarun        | 9999075499 | Madan Puri |    124 |     122001 |        91 |
|          2 | Ram          | 9650423377 | A-487      |     11 |     110085 |        91 |
|          3 | Sham         | 1111111111 | A-485      |     11 |     110085 |        91 |
|          4 | Mohan        | 1234567890 | 454        |    124 |     122002 |        91 |
+------------+--------------+------------+------------+--------+------------+-----------+

Order Table

+---------+------------+---------------------+-----------+
| OrderID | CustomerID | OrderDate           | ShipperID |
+---------+------------+---------------------+-----------+
|       1 |          1 | 2019-10-02 21:23:12 |        11 |
|       2 |          3 | 2019-10-02 21:23:27 |        12 |
|       3 |          5 | 2019-10-02 21:39:21 |        12 |
+---------+------------+---------------------+-----------+

INNER JOIN Query

use Shopping;
SELECT C.CustomerName, O.OrderID
FROM Customer C
INNER JOIN Orders O
ON C.CustomerID = O.CustomerID
ORDER BY C.CustomerName;

Output

+--------------+---------+
| CustomerName | OrderID |
+--------------+---------+
| Sham         |       2 |
| Tarun        |       1 |
+--------------+---------+