Top Menu

Search This Blog

SQL INNER JOIN

The INNER JOIN selects all record from both tables as there is a match between the columns in both tables.

Syntax:


SELECT *
FROM table_1
JOIN table_2
ON table_1.column_some_name=table_2.column_some_name

OR

SELECT *
FROM table_1
INNER JOIN table_2
ON table_1.column_some_name=table_2.column_some_name

Example:
         













As you see,In this tutorial we have two tables like this table(1) "Departments" and table(2)  "Employee".

Table 1 (Departments):

















Table 2(Employee):















select e1.Username,e1.FirstName,e1.LastName,e2.DepartmentName
from Employee e1 inner join Departments e2 on e1.DepartID=e2.id 

Output:



Post a Comment

Designed by OddThemes | Distributed By Gooyaabi Templates