SQL INNER JOIN एक JOIN operation है जिसका उपयोग दो या दो से अधिक टेबल्स को एक common column (आमतौर पर primary key और foreign key) के आधार पर जोड़ने के लिए किया जाता है। यह केवल वही रिकॉर्ड लौटाता है जो दोनों टेबल में match करते हैं।
SELECT table1.column1, table2.column2, ...
FROM table1
INNER JOIN table2
ON table1.common_column = table2.common_column;
मान लीजिए हमारे पास दो टेबल हैं:
+----+----------+--------+
| ID | Name | DeptID |
+----+----------+--------+
| 1 | Amit | 101 |
| 2 | Suman | 102 |
| 3 | Ramesh | 103 |
+----+----------+--------+
+--------+------------------+
| DeptID | DepartmentName |
+--------+------------------+
| 101 | Computer Science |
| 102 | Mathematics |
| 104 | English |
+--------+------------------+
SELECT Students.Name, Departments.DepartmentName
FROM Students
INNER JOIN Departments
ON Students.DeptID = Departments.DeptID;
+--------+------------------+
| Name | DepartmentName |
+--------+------------------+
| Amit | Computer Science |
| Suman | Mathematics |
+--------+------------------+
Ramesh और English शामिल नहीं हुए क्योंकि उनके DeptID
match नहीं करते हैं।
SQL INNER JOIN का उपयोग करके आप दो टेबल्स को एक common field के आधार पर जोड़ सकते हैं और केवल वही data प्राप्त कर सकते हैं जो दोनों टेबल्स में मौजूद हो। यह JOIN का सबसे ज़्यादा इस्तेमाल होने वाला type है।