关于一个子查询的问题
用子查询的方法查找所有收入在2500以下的雇员情况
use yggl
select*
from employees
where employeeid=
(select employeeid
from salary
where income < 2500
)
go
提示错误:子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。
要怎么修改?
哪位高手告诉一下。
多谢!!
问题点数:10、回复次数:4Top
1 楼seraphw(天平@-@)回复于 2006-03-16 12:55:53 得分 10
把等号改成in
use yggl
select*
from employees
where employeeid in
(select employeeid
from salary
where income < 2500
)
go
等号要求子查询返回一个值,而你的子查询中返回的是所有income < 2500的员工号集合,所以出错。
Top
2 楼patann()回复于 2006-03-16 13:00:23 得分 0
use yggl
select*
from employees
where employeeid in
(select employeeid
from salary
where income < 2500
)
go
Top
3 楼lcooc(don't make me think)回复于 2006-03-16 13:03:28 得分 0
use yggl
select*
from employees
where employeeid in
(select employeeid
from salary
where income < 2500
)
goTop
4 楼aniude(重返荣耀)回复于 2006-03-16 14:32:33 得分 0
--------------------------------
说明你的select 子查询返回的结果不只一个,where employeeid=无法匹配Top




