SQLWarningRuntime ErrorJune 14, 2026

Runtime Error

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

What This Error Means

This error occurs when a subquery is used in a way that expects a single value, but the subquery returns multiple values. This can happen when using a subquery in a WHERE or FROM clause with an operator that expects a single value.

Why It Happens

This error typically happens when a subquery is not properly correlated with the outer query, or when a subquery is used in a context where a single value is expected, but multiple values are returned. This can be due to a misunderstanding of subquery syntax or a failure to properly use aggregate functions to return a single value.

How to Fix It

  1. 1To fix this error, ensure that the subquery is properly correlated with the outer query using a join or a correlated subquery. Alternatively, use an aggregate function such as MAX or MIN to return a single value from the subquery. For example:
  2. 2// Before (broken code)
  3. 3SELECT * FROM orders WHERE product_id = (SELECT product_id FROM products WHERE category = 'Electronics');
  4. 4// After (fixed code)
  5. 5SELECT * FROM orders WHERE product_id = (SELECT MAX(product_id) FROM products WHERE category = 'Electronics');

Example Code Solution

❌ Before (problematic code)
SQL
SELECT * FROM orders WHERE product_id = (SELECT product_id FROM products WHERE category = 'Electronics');
✅ After (fixed code)
SQL
SELECT * FROM orders WHERE product_id = (SELECT MAX(product_id) FROM products WHERE category = 'Electronics');

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

Related SQL Errors

Related SQL Blog Articles

Have a different error? Get an instant explanation.

Explain Another Error