Monday 18 October 2010

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, , >= or when the subquery is used as an expression.

i written the below query statement to sql server..

Collapse
SELECT ReferringPhysician.LastName,ReferringPhysician.FirstName,
(SELECT LocationName FROM RefPhysLocations WHERE ReferringPhysicianID = (SELECT ReferringPhysicianID FROM RefPhysLocations WHERE LocationName LIKE '%'+@keyword+'%')) AS LocationName
FROM ReferringPhysician
WHERE ReferringPhysician.ReferringPhysicianID=(SELECT ReferringPhysicianID FROM RefPhysLocations WHERE LocationName LIKE '%'+@keyword+'%')


But, i got the following error message from sql server.

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

1 comment:

  1. finally i solved the problem...based on below..


    SELECT ReferringPhysician.LastName ,ReferringPhysician.FirstName,RefPhysLocations.LocationName
    FROM ReferringPhysician LEFT JOIN RefPhysLocations
    ON ReferringPhysician.ReferringPhysicianID = RefPhysLocations.ReferringPhysicianID
    WHERE LocationName LIKE '%'+@keyword+'%'

    ReplyDelete