MySQL帮助 - 员工在单个任务中工作超过50个小时?使用子查询?

时间:2013-03-10 23:52:26

标签: mysql sql

我有2个表,任务和员工。它们通过EmployeeNumber链接,HoursWorked是存储在赋值中的属性。我试过这个,我得到一个错误,说子查询返回超过1行。我做错了什么:

SELECT e.FirstName, e.LastName
FROM employee e
WHERE (
    SELECT a.HoursWorked
    FROM assignment a
    WHERE a.HoursWorked > 50); 

2 个答案:

答案 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);