DECLARE @productID INT SELECT @productID = ProductID FROM dbo.us_UserOrder WHERE ZJID = @ZJID SELECT COUNT( 0 ) FROM dbo.us_UserBindPhone a INNER JOIN dbo.us_UserOrder b ON a.ZJID = b.ZJID WHERE ProductID = @productID AND STATUS <> 3 AND a.PhoneNumber = @PhoneNumber AND a.ZJID <> @ZJID AND a.Dr = 0