In This Article, You Will Know About SQL INNER JOIN.
SQL INNER JOIN – Before moving ahead, let’s know a bit about SQL JOINS.
Table of Contents
SQL INNER JOIN
The SQL INNER JOIN returns the common value in both tables.
Syntax
SELECT column_names
FROM Table_name1
INNER JOIN Table_name2
ON Table1.column_name = Table2.column_name;
Example Database
Table name: Data_1
S.No | Name | Class |
1 | Alex | 5 |
2 | Rolex | 6 |
3 | Salex | 7 |
4 | Jalex | 8 |
5 | Kalex | 9 |
Table name: Data_2
S.No | Roll_No | Section_ID |
6 | 451 | A |
7 | 452 | B |
8 | 453 | C |
9 | 454 | D |
10 | 455 | E |
Example: Use the INNER JOIN clause to return the matching query between the table.
SELECT Data_1.Name, Data_2.Roll_No
FROM Data_1
INNER JOIN Data_2
ON Data_1.S.No = Data_2.S.No
If there is any query common in the both table, then it returns query from the Name & Roll_No, otherwise it returns nothing.
Example: Use the INNER JOIN clause to return the matching query between the table.
SELECT Data_1.Name, Data_2.Roll_No Data_1.Class
FROM ((Data_1
INNER JOIN Data_2
ON Data_1.S.No = Data_2.S.No)
INNER JOIN Data_3
ON Data_1.S.No = Data_2.S.No);
If there is any query common in the both table, then it returns query from the Name & Roll_No, otherwise it returns nothing.
If you find anything incorrect in the above-discussed topic and have further questions, please comment below.