What is INNER JOIN in SQL?
With using Inner Join, we will be able to generate a merged table containing the matching values from the existing participating tables.
Table of Content
Introduction to Inner Join
Records with matching values in the participating tables are returned by a SQL INNER JOIN. As shown below, suppose we have two tables, A and B. Only records that are shared by Tables A and B will be obtained when SQL’s INNER JOIN is used on these two tables.
Syntax Breakdown:
SELECT columns
FROM tableA name
INNER JOIN tableB name
ON tableA.coumn_x = tableB.column_y;
where SELECT, INNER JOIN, and ON are the keywords, columns are the list of columns, tableA is the first table, tableB is the second table, and column_x and column_y are the columns for performing the INNER JOIN, followed by a semicolon.
SQL INNER JOIN Example
Let’s apply SQL INNER JOIN to two tables, the employee table, and the department table
Select employee.employeeID,employee.e_name,employee.e_DepartmentID, department.departmentID,
department.DepartmentName from employee
INNER JOIN department
ON employee.e_DepartmentID = department.DepartmentID;
After writing the query, click on the execute button to check for errors. Once the query is executed, a message appears like ‘Commands completed successfully.
This brings us to the end of this INNER JOIN in SQL tutorial section. Go ahead and link the tables from your database to get a better insight into your data.
Our SQL Courses Duration and Fees
Cohort starts on 14th Jan 2025
₹15,048
Cohort starts on 21st Jan 2025
₹15,048