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:
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.
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.
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.
A selected expression can hold one value, not two columns. If you need both fields, join the table instead.
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.
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
JOINis often the clearer solution. - After fixing the column count, also verify that the subquery returns the expected number of rows.

