In this lesson we are going to study about Self joins in a database.
Self Join:
Example:-To find the name of Abhishek and Aritra manager we need to
sql query :-
In simulate two table in the from clause there are two aliases ,namely emp and manager for the same table ,EMPLOYEE.
Related Article
Self Join:
- In order to join a table to itself we use the self join.
- This type of join is used to compare values between two columns in the same table .
Example:-To find the name of Abhishek and Aritra manager we need to
- find in EMPLOYEE table by looking the Emp_name columns.
- find the manager number from Manager_id.
- find the name of manager with manager_id.
sql query :-
select
emp.Emp_Name
as Employee_name,
manager.Emp_Name
as manager_name
from employees emp,
employees manager
where emp.manager_id=manager.emp_id
OUTPUT:
Related Article
- Join
- Cross Join
- Equi Join
- Non Equi Join
- Natural Join
- Join with Using clause.
- Join with ON clause
- Outer Join
use alias in the table a lots of time could been managed look at my blogs--- https://sites.google.com/site/expersqldeveloper
ReplyDeleteHi
DeleteThanks for sharing your point on alias .
I whould like to add few point on why using alias name..
1.its reduce the code length ,sometime TableName is complex enough to write the same TableName.ColumnName so in place of TableName we use the Table alias Name.
2.By providing the (FQN) fully Qualified object Name it also reduce the query execution time.
hope this will help you.
for more reply.
Hey there! Do you know if they make any plugins to assist with SEO?
ReplyDeleteI'm trying to get my blog to rank for some
targeted keywords but I'm not seeing very good success.
If you know of any please share. Kudos!
Feel free to visit my page: rowing machine speed
I like the helpful information you provide in your articles.
ReplyDeleteI will bookmark your blog and check again here frequently.
I am quite sure I'll learn a lot of new stuff right here!
Best of luck for the next!
Also visit my blog post ... Buy now