我有2个表,任务和员工。它们通过EmployeeNumber链接,HoursWorked是存储在赋值中的属性。我试过这个,我得到一个错误,说子查询返回超过1行。我做错了什么:
SELECT e.FirstName, e.LastName
FROM employee e
WHERE (
SELECT a.HoursWorked
FROM assignment a
WHERE a.HoursWorked > 50);
答案 0 :(得分:1)
看起来你正试图做这样的事情:
SELECT e.FirstName, e.LastName
FROM employee
JOIN assignment on employee.EmployeeNumber = assignment.EmployeeNumber
WHERE assignment.HoursWorked > 50;
答案 1 :(得分:0)
SELECT e.FirstName, e.LastName
FROM employee e
WHERE e.EmployeeNumber IN (
SELECT EmployeeNumber
FROM assignment a
WHERE a.HoursWorked > 50);