Last answered:

16 Nov 2022

Posted on:

14 Nov 2022

0

Where in subquery

For this lesson I put the below without the t.emp_no = e.emp_no  AND , I received a 100 rows back however not the same as the answer. it seems as if this is part is similar to the ON statement in a JOIN  t.emp_no = e.emp_no do we need to put a "ON" statement anytime we do a where. A
SELECT
    *
FROM
    employees e
WHERE
    EXISTS( SELECT
            *
        FROM
            titles
        WHERE
            title = 'Assistant Engineer')
order by emp_no;

1 answers ( 0 marked as helpful)
Instructor
Posted on:

16 Nov 2022

0

Hi Linda!
Thanks for reaching out.

If you do not use t.emp_no = e.emp_no, the query would always be true and it will result in returning all the values from the employees table. It is different. The ON clause should be used to define the join condition and WHERE should be used to filter the data.

Hope this helps.
Best,
Tsvetelin

Submit an answer