我有这个查询:
SELECT * FROM `employee_activities` a
LEFT JOIN `activity` b ON a.activity_code = b.code
LEFT JOIN `employees` c ON a.employee_code = c.code
WHERE b.type = "Design"
AND c.code NOT IN(
SELECT * FROM `employee_activities` a
LEFT JOIN `activity` b ON a.activity_code = b.code
LEFT JOIN `employees` c ON a.employee_code = c.code
WHERE b.type = "Testing"
)
GROUP BY c.code
我收到此错误:
#1241 - Operand should contain 1 column(s)
我想让所有员工至少有一项“设计”类型的活动和没有“测试”类型的活动。
我有一个有效的查询,但我希望它可以与联接一起使用。
这有效:
SELECT c.name FROM `employee_activities` a, `activity` b, `employees` c
WHERE a.activity_code = b.code
AND a.employee_code = c.code
AND b.type = "Design"
AND c.code NOT IN(
SELECT c.code FROM `employee_activities` a, `activity` b, `employees` c
WHERE a.activity_code = b.code
AND a.employee_code = c.code
AND b.type = "Testing"
)
GROUP BY c.code
我在连接的 sql 上做错了什么?