I am using two sub query. If I pass null or empty value its throwing exception
Exception message
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
My query
SELECT A.Product_Name AS [Product Name], A.Product_Id AS [Product Id], B.[DuplicateId]
FROM tb_new_product_Name_id AS A,
(
SELECT COUNT(Product_id)+1 AS [Duplicate Id]
FROM tb_new_product_Name_id_duplicate
WHERE Product_id= (SELECT Product_id
FROM tb_new_product_Name_id
WHERE Product_Name=@product_name_id
)
) AS B
WHERE Product_Name LIKE '%'+@product_name_id+'%' OR Product_Id like '%'+@product_name_id+'%';
Where is my mistake?