用户
 找回密码
 入住 CI 中国社区
搜索
12
返回列表 发新帖
楼主: nymbian
收起左侧

[HELP] 帮忙看下这段SQL怎么写

[复制链接]
 楼主| 发表于 2011-6-3 15:25:02 | 显示全部楼层
SQL复制代码
 
SELECT *
FROM staffs
WHERE staffs.department_id = (
SELECT department.department_id
FROM department
WHERE department.department_name =   '行政部' )
UNION
SELECT *
FROM staffs
WHERE staffs.department_id IN (
SELECT low_department_id
FROM department_department
WHERE department_department.high_department_id = (
SELECT department.department_id
FROM department
WHERE department.department_name =   '行政部' )
 
)
 
复制代码

再更新下
 楼主| 发表于 2011-6-3 15:26:08 | 显示全部楼层
visvoy 发表于 2011-6-3 13:18
这种子子子查询看的蛋疼,你能不能用2条查询实现?

已经改成两条了

本版积分规则