Using Inner Join:
It selects rows from both tables as long as there is a match between the column on which join is applied. Inner join is used to fetch data from more than one table.
Syntax:
SELECT columnname(s) FROM tablename1 INNER JOIN tablename2 ON tablename1.columnname=tablename2.columnname;
Example:
SELECT Employee.Name, Department.DeptID
FROM Employee
INNER JOIN Department
ON Employee. EmpID= Department. EmpID;
It will select those employee name and there respective department IDs whose EmpID in both tables are same.
0 Comment(s)