Q:

How to solve oracle joins when trying to give input dynamically

I am lucky and i am new to oracle.
I need to retrieve the data from emp table and dept table based on given input deptno and JOB
SELECT

ENAME, E.DEPTNO, JOB , LOC FROM

EMP E , DEPT D where e.deptno=&dno and job ='&JOB' ;

if I enter 10 and clerk
If I write query like this it needs to display only MILLER Record only but the output like as below
MILLER    10    CLERK    NEW YORK

MILLER    10    CLERK    DALLAS

MILLER    10    CLERK    CHICAGO

MILLER    10    CLERK    BOSTON

But i need output like
 MILLER    10    CLERK    NEW YORK

because he belongs to 10th dept and the location is NEW YORK
Please help me on this.

A:

You need to join emp and dept table try
SELECT

ENAME, E.DEPTNO, JOB , LOC FROM

EMP E , DEPT D where e.deptno=&dno 
and e.deptno=d.deptno 
and job ='&JOB' ;

