Sunday, 20 November 2011



Self Join - The Self Join is a join condition in table it self join in different attribute with in table.
We have following "Emp_Table" name table"

Emp_IDNameCountryDept_ID
123JayIndia21
124AjayIndia23
145/td>SteinbergIndia23
201RobinsonUK24
305BhaveshCanada24
306JohnCanadaNULL


Self Join Example

Example Statement:
SQL> SELECT F.Emp_ID, F.Name, S.Emp_ID, S.Name, F.Country
 FROM Emp_Table F, Emp_Table S
  WHERE F.Country = S.Country
   AND F.Emp_ID < S.Emp_ID
    ORDER BY F.Emp_ID, S.Emp_ID;
Example Result:
Emp_IDNameEmp_IDNameCountry
123Jay124JonesIndia
123Jay145SteinbergIndia
124Ajay145SteinbergIndia
305Bhavesh306JohnCanada




0 comments:

Post a Comment

TrainingHUB. Powered by Blogger.

Total Pageviews

THE BEST QTP TRAINING INSTITUTE IN HYDERABAD

QTP Training in hyderabad

Sql Tutorial

Popular Posts

Our Facebook Page

TrainingHUB

Followers