top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is difference between self join vs inner join?

0 votes
570 views
What is difference between self join vs inner join?
posted Jun 29, 2018 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

Inner Join
A join which is based equality condition is called inner join or equijoin

Syntax:

select table1.column1, table2.column2.... from table1, table2
where table1.column=table2.column
or
select table1.column1, table2.column2.... from table1 inner join table2
on table1.column=table2.column

select ename, job, emp.deptno, dept.deptno, dname, loc  from emp, dept where emp.deptno=dept.deptno
or 
select ename, job, emp.deptno, dept.deptno, dname, loc from emp inner join dept 
on emp.deptno=dept.deptno

Self Join
Joining the tables itself is called self join.

select worker.empno, worker.ename, manager.ename,manager.empno  from emp worker, emp manager
where worker.mgr = manager.empno
answer Jul 4, 2018 by Vijay
0 votes

Self Join
A self join is a join in which a table is joined with itself (which is also called Unary relationships), especially when the table has a FOREIGN KEY which references its own PRIMARY KEY.
Inner Join
The INNER JOIN creates a new result table by combining column values of two tables (table1 and table2) based upon the join-predicate.

answer Jun 30, 2018 by Madhavi Latha
...