Search:     Advanced search
Browse by category:
C/C++   |   Java   |   Oracle/Database   |   SAP   |   ASP .NET   |   Mainframe-DB2   |   Freshers

Q: Explain Normal Join

Add comment
Views: 511
Votes: 0
Comments: 0

A normal join will look like the following

SELECT e.ename NAME, d.deptname DEPARTMENT
FROM emp e, dept d
WHERE e.deptno = d.deptno;
Here the tables emp and dept have been joined by the column deptno. Please note the use of  table alias (emp e) and column alias (
e.ename NAME) in this statement.

 

Explain Concept of Self Join

When a table is joined to itself in a query then that is called a self-join.
The structure of emp table is

eno ename mgrno
Employee No Employee Name Manager Number

Data in the table is
eno ename mgrno
1 suku 2
2 pari 3

Now we want to find the name of the manager of the employee named 'suku'. This can be done by the following query
Select mgr.ename "Manager Name"
 From  emp e, emp mgr
Where e.mgrno=mgr.eno
Here the emp table is joined with itself. So this is a self join.

Others in this Category
document What are the advantages of using Stored Procedures?
document What is XML Datatype?
document Q: What is CYCLE/NO CYCLE in a Sequence ?
document What is Difference between Function and Stored Procedure?
document What is NOT NULL Constraint?
document How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?
document Q: What is pseudo columns ? Name them?
document What is Catalog Views?
document Q: Explain the concept of NULL
document What is difference between DELETE & TRUNCATE commands?
» More articles



RSS