Hi guys. Im trying to do a self join on SQL and I hit a road block in my studies. The mysports. needs to be before the emp or it cannot find the table, all online tuts dont have the table identity to worry about.
its an Oracle Database
SELECT emp.deptno, emp.ename as "Employee N", emp.empno, emp.mgr
FROM mysports.emp INNER JOIN
mysports.emp ONemp.mgr = emp.empno
WHERE deptno = 10 OR deptno = 20
;
the mgr needs to display the name of the manger not his id number
How do you make these SQL maps?
>Inner joining a table on itself
for what purpose
>>59131417
For example, you've got a table with Citizens that contains a column called "Married to" and you want to display who is married to whom
In that case I would have a table marriage with two fields, personA, personB, both foreign keys and forming a composite primary key...
SELECT e1.deptno, e1.ename, e1.empno, e2.name FROM emp as e1, emp as e2 WHERE e1.mgr = e2.empno;
>>59131306
UML?
Graphviz?
get creative.
>mfw a table near me isn't normalized to even 1NF