=> Use NON equi join when two or more tables are not sharing the common column.
Syntax:
=> Select <collist> from <tablelist> where <join condition> [ and <join condition>.... ]
Examples:
1. Display employee names and grades ?
=> Select e.ename, s.grade from emp e, salgrade s where e.sal between s.lowsal and s.highsal;
(or)
=> Select e.ename, s.grade from emp e JOIN salgrade s ON e.sal between s.lowsal and s.highsal;
2. Display employee names working in Newyork location and having grade >=2 ?
=> Select e.ename, d.loc, g.grade from emp e, dept d, salgrade g where e.depto = d.deptno
and ( e.sal between s.lowsal and s.highsal ) and d.loc = 'NEWYORK' and g.grade >=2;
(or)
=> Select e.ename, d.loc, g.grade from emp e
JOIN dept d ON ( e.depto = d.deptno AND d.loc = 'NEWYORK' )
JOIN salgrade g ON ( e.sal between s.lowsal and s.highsal AND g.grade >=2)
Syntax:
=> Select <collist> from <tablelist> where <join condition> [ and <join condition>.... ]
Examples:
1. Display employee names and grades ?
=> Select e.ename, s.grade from emp e, salgrade s where e.sal between s.lowsal and s.highsal;
(or)
=> Select e.ename, s.grade from emp e JOIN salgrade s ON e.sal between s.lowsal and s.highsal;
2. Display employee names working in Newyork location and having grade >=2 ?
=> Select e.ename, d.loc, g.grade from emp e, dept d, salgrade g where e.depto = d.deptno
and ( e.sal between s.lowsal and s.highsal ) and d.loc = 'NEWYORK' and g.grade >=2;
(or)
=> Select e.ename, d.loc, g.grade from emp e
JOIN dept d ON ( e.depto = d.deptno AND d.loc = 'NEWYORK' )
JOIN salgrade g ON ( e.sal between s.lowsal and s.highsal AND g.grade >=2)
No comments:
Post a Comment