Join Query
Join Query
Pushpa Choudhary
JOIN QUERY
SQL (Join Query)
Join Query:
It is used to relate two or more tables in the form of Parent/Child
relationship.
Equi Join:
When two tables relation is based on Common Columns / Values (or based on
Equality). For example: EMP and DEPT tables are related via DEPTNO common
column (like emp.deptno = dept.deptno).
Example:
This type of JOIN returns the Cartesian product of rows from the tables in Join. It will return a
table which consists of records which combines each row from the first table with each row of
the second table.
SELECT column_COLUMN_LIST FROM table_NAME1 CROSS JOIN
table_NAME2;
SELECT * FROM EMP CROSS JOIN DEPT;
OR
SELECT * FROM EMP,DEPT;
INNER Join or EQUI Join
This is a simple JOIN in which the result is based on matched data as per the equality condition
specified in the SQL query.
Natural Join is a type of Inner join which is based on column having same name and same
datatype present in both the tables to be joined.
OR
Select E.ename "employee_name", M.ename "manager_name" from EMP E,EMP M
Where E.mgr=M.empno;
• Display those employees who joined the company before their Managers
• Display all Employees name and Managers name including the Employee not
having a Manager.
SELECT E.ename, M.ename FROM emp E, emp M
WHERE E.mgr = M.empno(+);