Saturday, October 4, 2008

Joining Conditions in Oracle

If we have so many tables in FROM clause its very hard to keep track of joining conditions in WHERE Clause. So here is the simple way to remember it.
If we have N tables in FROM Clause, we need at least N-1 jion conditions in WHERE Clause to avoid a Cartesian product.

SELECT E.EMPID,E.ENAME,D.DEPTNO,D.DNAME
FROM EMPP E, DEPT D
WHERE D.DEPTNO = E.DEPTNO

You can see two tables and 1 condition...

No comments: