Sneha K

Sneha K

  • 1.2k
  • 527
  • 196.7k

Self Join? and how to write self join for more than 3 tables

Apr 9 2016 7:35 AM

Hi i have learned about inner join, left join ,right join, outer join but i donno what is self join?. Any one explain me what is self join and it uses and also where to use.

Then also i want to know how to join more than three tables using self join.

Eg Customer Table
 
1)CustomerID uniqueidentifier primary key not null, 2)CustomerName Varchar(100), 3)CustomerTypeID uniqueidentifier null.
 

CustomerType

1)CustomerTypeID uniqueidentifier primary key not null 2)CustomerType varchar null

CustomerAddress Table

1)CustomerAddressID uniqueidentifier primary key not null 2)CustomerID uniqueidentifier null, 3)AddressID uniqueidentifier null,

Address

1)AddressID uniqueidentifier primary key not null, 2)Street varchar(100) null, 3)Location varchar(100) null, 4)Place varchar(100), null, 5)AreaID uniqueidentifier null, 6)PinCode .Varchar(100)

Area

1)AreaID uniqueidentifier primary key not null, 2)Area Varchar(100).

 

Here i mention some tables. Now i want to display CustomerName , CustomerType, Street,Place,Location, Area, PinCode. Now how i put self join for these tables . please any one explain this concept.

Advance Thanks...

 

Answers (2)