Last answered:

14 Mar 2024

Posted on:

14 Mar 2024

0

How could I see the title colum in this subquery?

I'd like the output of this code to show the title of the employee in order to verify the result truly is only Assistant Engineers

select *
from employees
where exists (select * from titles where title="Assistant Engineer");

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

14 Mar 2024

0

Hi David!

Thanks for reaching out!

While WHERE EXISTS is useful for checking if a certain condition is met in a subquery, it doesn't allow you to directly display specific columns from the subquery in your result set, like the employee's title. 

To include the title in your output while verifying that the employee is an "Assistant Engineer," you would typically use a JOIN operation. This allows you to combine columns from two tables based on a related column between them and display the relevant columns. 

We cover JOINS later in the course.

Hope this helps.

Best,

Ivan

Submit an answer