EQUI JOIN or INNER JOIN

In SQL join means, two or more related tables join together by their two common characterize columns one is primary key another is detail or foreign key in those tables.

In SQL, INNER or EQUI join means records in detail table will be returned only when detail or foreign key column values are matched with primary key column of master table, if so then matches of combine records will be returned otherwise null will be returned. I am trying to give an example below for your better understanding.

Suppose we have two tables one is Department Table and another is employee table, and we have to make sure that every and each employee has a department, that means each employee has a department id, in order to this criteria ID of department table is our master table or primary table and DEPTID of employee table is our foreign table or detail table.Let examine our department and employee table below.

id dept
1 IT
2 Sales
3 Marketing


Employee Table

id Name Position Deptid
1 Moinuddin(Peal) Lead Developer 1
2 Jhon Doe MM 3
3 Jack NSM 2


 

Above two tables can be joined together using INNER join or EQUI join like as

Select e.id,e.name,e.position,d.dpet
from employee e
INNER JOIN department d
on e.deptid = d.id

So,than our output will be like below

id Name Position Department
1 Moinuddin(Peal) Lead Developer IT
2 Jhon Doe MM Marketing
3 Jack NSM Sales


Hope, you have understood.


Posted

in

by

Tags:

Comments

Leave a comment