What is a self join? Explain it with an example?
Answer Posted / sushant more (sybase dba)
CREATE TABLE EMPLOYEE(
[EMPLOYEE_ID] INT PRIMARY KEY,
[NAME] NVARCHAR(50),
[MANAGER_ID] INT
)
GO
INSERT INTO EMPLOYEE VALUES(101,'Mary',102)
INSERT INTO EMPLOYEE VALUES(102,'Ravi',NULL)
INSERT INTO EMPLOYEE VALUES(103,'Raj',102)
INSERT INTO EMPLOYEE VALUES(104,'Pete',103)
INSERT INTO EMPLOYEE VALUES(105,'Prasad',103)
INSERT INTO EMPLOYEE VALUES(106,'Ben',103)
select e1.NAME from EMPLOYEE e1,EMPLOYEE e2
where e1.EMPLOYEE_ID = e2.MANAGER_ID
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Explain the role of indexing in databases?
What is DB Development software?
What is dbms explain in brief?
What is normalization? Explain different levels of normalization?
How to combine two function together?
Does QTP Support the Propjects which are running in Dot Net? As we are starting with new project in Dot net need to use automation tool?Please advice & let me know what would be the best.
If a column is an image value type, how you can compare column values? How can you use this column in join clause?
What are the main phases of database development?
Write short notes on manual refreshes.
How can you fix a poorly performing query?
The count() function always returns a int value type what should you do if you need to count rows from a query which you know will return a value that is too large for an int value type?
How to use online Backups?
Write the fastest query to find out how many rows exist in a table?
fact table and dimension table containg one to many relationship or many to one relastionship
What are data modelling techniques?