Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Answers were Sorted based on User's Feedback



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

Answer / ramya

CREATE TABLE EMPLOYEE(

[EMPLOYEE_ID] INT PRIMARY KEY,

[NAME] NVARCHAR(50),

[MANAGER_ID] INT

)



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.employee_id,e1.name,e1.manager_id,e2.name from
employee e1 join employee e2
on e1.employee_id = e2.manager_id

Is This Answer Correct ?    1 Yes 0 No

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

Answer / mona

A table join to itself is known as self join.

select emp.ename,mngr.ename from emp.empl,emp.mngr where
emp.mngrno=mngr.empno

Is This Answer Correct ?    15 Yes 16 No

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

Answer / vijayan.t

A table join to itself is known as self join.


select e1.empid,e1.empname,e1.empmgrname where empmgrid =
empid;

here in a single table e1 having three fields(employee id,
employee name,manager id)one employee's manager id is
another one employee's employee id so compare that 2 ids and
we can get the particular employee's manager name...

Is This Answer Correct ?    4 Yes 5 No

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

Answer / pradeep sharma (http://www.tec

create table emp
(
empid int,
mgrid int,
empname varchar(50)
)
insert into emp values(1,2,'a')
insert into emp values(2,3,'b')
select * from emp

select e.empname as employee,d.empname as mgr from emp e
inner join emp d
on d.empid=e.mgrid

Is This Answer Correct ?    0 Yes 1 No

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

Answer / mike

You lost one Anju as Employee , because Anju does not have a
manager.
You should use left outer join in this case.

select e1.emp_name 'manager',e2.emp_name 'employee'
from employees e1 left outer join employees e2
on e1.emp_id=e2.emp_manager_id

Is This Answer Correct ?    0 Yes 2 No

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

Answer / nishant dubey

Table join itself using alias..
example
Select N,emp_id,N.emp_name,D.emp_id,D.emp_name from Nishant
N,Nishant D where N.emp_id=D.emp_id;

Is This Answer Correct ?    11 Yes 19 No

Post New Answer

More DB Development Interview Questions

In which table collections errors are stored.

0 Answers  


what is the use of foreginkey

2 Answers  


How to read and create .LDC data files which are used by linguatic dictionary.

0 Answers  


hi in which phase of mload can i use .FILLER

1 Answers   IBM,


What are defaults? Is there a column to which a default can't be bound?

2 Answers  


What are data modelling techniques?

0 Answers  


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

0 Answers  


What is the system function to get the current user's user id?

4 Answers  


Can you instantiate a COM object by using T-SQL?

1 Answers  


Explain about the database management systems.

0 Answers  


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

0 Answers  


Any sample or model question of punjab national bank for deputy manger IT or any sample of PNB.any1 plz do send on

0 Answers  


Categories