MySQL
SQL Error
Database Tutorial
Operand Error
SQL Query

MySQL - Operand should contain 1 columns

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

The MySQL error “Operand should contain 1 column(s)” means SQL expected a single value, but your query supplied more than one column. This usually happens with subqueries used in scalar contexts such as =, IN, or the SELECT list.

The Typical Cause

A scalar subquery must return exactly one column. This is invalid because the subquery returns two columns where one value is expected:

sql
1SELECT *
2FROM orders
3WHERE customer_id = (
4    SELECT id, email
5    FROM customers
6    WHERE id = 10
7);

MySQL does not know how to compare customer_id to a two-column row in that context.

Fix by Returning One Column

If the intention is to compare against one value, return one column.

sql
1SELECT *
2FROM orders
3WHERE customer_id = (
4    SELECT id
5    FROM customers
6    WHERE id = 10
7);

That makes the subquery scalar and valid.

Use Tuple Comparison Only When You Mean a Tuple

Sometimes you really do want to compare multiple columns. In that case, both sides of the comparison must be row expressions of matching shape.

sql
1SELECT *
2FROM orders
3WHERE (customer_id, status) = (
4    SELECT customer_id, status
5    FROM archived_orders
6    WHERE order_id = 5
7);

That is a different query shape from a scalar comparison. The important part is that both sides now contain two columns.

The Error Also Appears in the SELECT List

Another common mistake is trying to place a multi-column subquery inside a single selected expression.

sql
1SELECT (
2    SELECT id, email
3    FROM customers
4    WHERE id = 10
5) AS customer_info;

A selected expression can hold one value, not two columns. If you need both fields, join the table instead.

sql
SELECT c.id, c.email
FROM customers c
WHERE c.id = 10;

Often the Real Fix Is a JOIN

If you are trying to pull related data, a JOIN is usually clearer than squeezing multiple columns through a subquery.

sql
1SELECT o.order_id, c.id, c.email
2FROM orders o
3JOIN customers c ON c.id = o.customer_id
4WHERE o.order_id = 42;

This is easier to read and usually closer to the actual relational intent.

Check Cardinality Too

Even after fixing the column count, remember that some subquery contexts also expect exactly one row. If the subquery returns multiple rows, you will get a different error.

So there are really two separate checks:

  • does the subquery return the correct number of columns
  • does the subquery return the correct number of rows for this context

Do not stop debugging after fixing only one of them.

Read the Query From the Expected Shape Outward

A practical debugging habit is to ask, "Does this position expect one value, one row, or a full table result?" Once you answer that, the bad subquery shape usually becomes obvious.

That framing is faster than staring at the SQL text generally, because this error is fundamentally about shape mismatch rather than about syntax alone.

Common Pitfalls

The biggest mistake is returning several columns from a subquery used with = or in a single-value expression.

Another issue is using a scalar subquery where a join or tuple comparison would better express the query.

A third problem is fixing the column count but forgetting that the subquery may still return too many rows.

Summary

  • This MySQL error means a query expected one column but received more than one.
  • Scalar subqueries must return exactly one column.
  • If you intend to compare multiple columns, use a tuple comparison on both sides.
  • If you want related fields, a JOIN is often the clearer solution.
  • After fixing the column count, also verify that the subquery returns the expected number of rows.

Course illustration
Course illustration

All Rights Reserved.