Last answered:

21 Apr 2023

Posted on:

15 Apr 2023

0

exists vs in. just checking my understanding

select *
from employees
where emp_no in(select emp_no
from titles
where title = 'Assistant Engineer');
I used this query and got the same no of rows returned. 
Assuming that this is indeed correct, we need to use e.title = t.title in case of exists because exists does not return any value but simply checks if the statement is true and in case of in, even if we just check for the given job title, as it is returning all the emp_no for which the title is Assistant Engineer we dont need to check for this condition.

Did I understand this correctly?

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

21 Apr 2023

0

Hi Samhitha!
Thanks for reaching out.


Yes, you got it right! If we use the EXISTS operator we need to add the condition you mentioned.


Hope this helps.
Best,
Tsvetelin

Submit an answer