Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Using this Query Get Missing Record


SQL
Select ServiceId, ClassId from  ServiceMaster, ClassMaster
Where Not Exists(Select ServiceId, ClassId from ServiceRateMaster where ServiceId =(Select ServiceId from ServiceMaster) and ClassId = (Select ClassId from ClassMaster  ))
Order By ServiceId ,ClassId


But Getting This Error from SQl



XML
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Posted
Comments
Sergey Alexandrovich Kryukov 25-Aug-14 13:05pm    
As the error suggests, your mistake is using '='. Apparently, one operand cannot be equal to more then one different records.
—SA

1 solution

Your code should have in operator in subqueries

SQL
Select ServiceId, ClassId from  ServiceMaster, ClassMaster
Where Not Exists(Select ServiceId, ClassId from ServiceRateMaster where ServiceId In(Select ServiceId from ServiceMaster) and ClassId in (Select ClassId from ClassMaster))
Order By ServiceId ,ClassId
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Aug-14 13:06pm    
The key is getting rid of '=', which was clearly explained in the error message. A 5.
—SA

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