SELECT
student.Student_Name
FROM
`student`
GROUP BY
student.Student_ID,
teacher.Department_No IN (
SELECT
teacher.Department_No
FROM
`teacher`, `building`
WHERE
teacher.Department_No BETWEEN 1000
AND 2999
GROUP BY
teacher.Department_No = (
SELECT
*
FROM
`building`
WHERE
building.Building_No IN ( '1', '2')
)
) LIMIT 0, 25
2条答案
按热度按时间zphenhs41#
您的sql有两个问题:
你需要使用
IN
而不是=
或者将子查询限制为只有一条记录您需要使用指定列而不是
*
在子查询中使用
IN
```teacher.Department_No IN (
SELECT
Department_No
FROM
building
WHERE
building.Building_No IN ( '1', '2')
)
vuktfyat2#
您需要在子查询部分选择一列,如department\u id