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

Answer Posted / kannan

CREATE TABLE IF NOT EXISTS `emp` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) collate latin1_general_ci NOT NULL,
`dept_id` int(11) NOT NULL,
`mgr_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
)


SELECT e2.name Employee_name, e1.name Manager_name
FROM emp e1, emp e2
WHERE e2.mgr_id = e1.id

Is This Answer Correct ?    12 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write short notes on manual refreshes.

2294


What are data modelling techniques?

529


What are the 18 schemas?

615


What is the physical representation for a many-to-many relationship?

580


How to combine two function together?

1664






Explain about query and reporting.

1694


What is data modeling with example?

535


How to use timestamp datatypes

1583


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?

580


What are the key features of dbms?

571


Which data type cannot be used as a parameter in a udf?

580


You have two tables with a one to many join based on a field named id. You need to find records in the parent table that are not represented in the child table. how would you accomplish this?

598


If a column is an image value type, how you can compare column values? How can you use this column in join clause?

597


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


Explain about normal forms?

603