5 Nov 2017

What is self Join


What is self join:-

Self join is not join it is concept.self join can take only single table.

create table Employees
(
Eid int primary key identity(1,1),
Ename varchar(50),
Manager int
)

select * from Employees


truncate table Employees  // How to truncate table //

insert into Employees values('Varsha',9)
insert into Employees values('Pooja',5)
insert into Employees values('Nidhi',4)
insert into Employees values('Devesh',2)
insert into Employees values('Shiva',6)
insert into Employees values('Princi',8)
insert into Employees values('Usa',3)
insert into Employees values('Neelam',1)
insert into Employees values('Deepak',7)


select E2.Ename,E1.Ename from Employees E1 inner join Employees E2 on E1.Eid=E2.Manager


No comments:
Write comments

Popular Posts

Popular Posts

Translate

Total Pageviews