I saw this query that finds all the employees with more than one degree:
select id, name
from employee E
where exists (
select *
from academics A1, academics A2
where A1.emp_id = E.id and
A2.emp_id = E.id and
A1.discipline != A2.discipline
)
But why is the exists necessary? Why not just do:
select id, name
from employee E, academics A1, academics A2
where A1.emp_id = E.id and
A2.emp_id = E.id and
A1.discipline != A2.discipline
Are the two above equivalent?
academics). – ypercubeᵀᴹ Mar 09 '17 at 16:31academicshas a column namedidorname, the query will not know which table those columns in the select list come from. – RDFozz Mar 09 '17 at 16:34