문제

The following is the prompt i'm trying to answer:

Write the nested statement to list the first and last names of those employees who have the same job as Larry Smith.

The following is the employee table columns:

EMPLOYEE(Emp_Num, Emp_Lname, Emp_Fname,Emp_Initial, Emp_HireDate, Job_Code)

The following is my nested query:

select emp_fname, emp_lname
from EMPLOYEE
where job_code =
(select job_code
from employee
where emp_fname = 'larry'
and emp_lname = 'smith');

Why is this not working?

도움이 되었습니까?

해결책

You should be using IN not =:

select emp_fname, emp_lname
from EMPLOYEE
where job_code IN
  (select job_code
   from employee
   where emp_fname = 'larry'
     and emp_lname = 'smith');

The reason being that you are comparing a value to the set returned by the subquery.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top