I need to write a self join query
My Table is:-
id locid parentid filename
1 1 0 word
2 1 0 excel
3 1 1 power
4 2 0 word
5 2 4 power
I need to retrive only those data where parentid=0 using selfjoin
Thanks in Advance
From your query its not clear based on which do u want to use self join.
Anyway below is one example which will give u clear picture about self join.
Suppose Employees is table which contains data related to employees.
An Employee can be manager for other employee but single itself consider as employee for any organization.
Exmaple:
TableName : employees
Query:
OutPut will be as below: