TWO SQL queries on Self-join and Inner-Join

I have given two examples. Those are self and inner join.

SQL Query Inner Join

SELECT PROJNO,EMPNO,LASTNAME,DEPTNAME
FROM  (TEST.EMP E  JOIN       
TEST.DEPT  DON        
D.DEPTNO = E.WORKDEPT)  JOIN             
TEST.PROJ. P
ON        EMPNO = RESPEMP;

The above is the best example for finding match in 3 tables using Inner join.

SQL Query Self-Join

SELECT A.DEPTNO,A.DEPTNAME,
A.ADMRDEPT,A.DEPTNAMEFROM TEST.DEPT A             
TEST.DEPT B
WHERE A.ADMRDEPT =A.DEPTNO;

The above SQL query is the best example for self join.

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.