What is a self join? Explain it with an example?

Answer Posted / sanchit aggarwal(oracle dev.)

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 ?    31 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about the database management systems.

570


How to replace not in with not exist?

1470


How can you log an error to the server event log from a stored procedure?

562


What are the 18 schemas?

615


How to use timestamp datatypes

1583






What are the types of database model?

550


What is DB Development software?

1619


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.

1610


To convert IDMS to DB2, how to deal with IDMS occurs and redefined clause?

3441


Explain about xml databases?

626


How is data stored in dbms?

527


In which table collections errors are stored.

1942


Who are end users in dbms?

551


Hi , any one can help me on the same,this is regarding the Informatica Function doc,i want to know how developer is will develop the mapping. pl forwar the any function doc .just for my references. svlc75@yahoo.co.in

1591


What are data modelling techniques?

529