Pages

Ads 468x60px

Sql Self Join example with Images

Create Person table for Self Join example

create table tblPerson(P_ID int primary key, P_Fname varchar(20),P_Lname varchar(20),Gender varchar(10),P_Father int,P_Mother int)

insert into tblPerson values('Puran','Singh','M',null,null)

………….



Self join Example

select a.P_Fname,b.P_Fname from tblPerson as a

join tblperson as b on a.P_ID=b.P_Father

where a.P_Fname='ram'

No comments:

Post a Comment