I have a query:
SELECT emp.empno , emp.ename , emp.job , emp.sal , dept.dname , dept.loc
FROM emp ,
dept
WHERE emp.ename = 'SMITH';
Please tell me why this is displaying all the Records , as i am expecting only one record ?
EMPNO ENAME JOB SAL DNAME LOC
---------- ---------- --------- ---------- -------------- -------------
7369 SMITH CLERK 800 ACCOUNTING NEW YORK
7369 SMITH CLERK 800 RESEARCH DALLAS
7369 SMITH CLERK 800 SALES CHICAGO
7369 SMITH CLERK 800 OPERATIONS BOSTON
7369 SMITH CLERK 800 CREDIT
The reason is because your query lacks JOIN criteria to link the two tables, so the result will be a cartesian product. Every
EMPrecord will have a copy of every row in theDEPTtable…Your query uses ANSI-89 join syntax, which requires the criteria to be in the
WHEREclause:But it would be preferable to use the ANSI-92 format: