Click here to Skip to main content
14,926,224 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

I have write query which has 2 sub query
1 return 198 row
And other one return 168 so tell how to solve this problem

[Edit]Shouting removed - KH[/Edit]
Updated 15-Aug-12 0:14am

Dear Friend,

You can use Distinct or Group by or Top 1.
It will help you. But make sure that, your requirement is fulfilled.
Instead of =, use In

I think your query will be looking something like
select * from employee where empid=(select empid from employee where dept='SE')

So now what happens, the subquery will return you more than one row but since you mentioned condition'=', it returns error.

In that case, you have to use IN or exists

select * from employee where empid in (select empid from employee where dept='SE')

In case if you used !=, then use not in.

But note: Not in will affect performance use not exists

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900