SELECT ENAME, EMP.JOB,DEPT.DNAME
FROM EMP, DEPT
WHERE EMP.JOB=DEPT.DNAME;
This is giving the output as "no rows selected".
SELECT ENAME, EMP.JOB,DEPT.DNAME
FROM EMP, DEPT
WHERE EMP.JOB=DEPT.DNAME;
This is giving the output as "no rows selected".
Assuming that EMP.JOB=DEPT.DNAME
is right (something that i can not imagine) your query would be actually right, and you can join this like:
SELECT ENAME, EMP.JOB,DEPT.DNAME
FROM EMP inner join DEPT
ON EMP.JOB=DEPT.DNAME;
But this would'nt give other esults than your query, i guess the problem is that your confusing columns, usually references are done through an id column.
The Idea that EMP.JOB
which might be developer or programmer for example would match a DEPT.DNAME
which in this case would be development department for example is somehow wierd, i guess you take a second look at how your tables are connected with each other.
Generating a visual diagram from your database could be helpful, take alook at this thread fro further information: Tools to generate a database diagram/ER diagram from existing Oracle database?
I'm not sure what you want - the job will never be equal to dept name... Here's the correct join -copy/paste to run and see results:
SELECT d.deptno, ENAME, JOB, DNAME
FROM scott.EMP e, scott.DEPT d
WHERE e.deptno = d.deptno
ORDER BY d.deptno
/
FYI: The EMP.JOB=DEPT.DNAME will never be correct as in orig question/query.