Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-29 · container image mysql:8.4
ERROR 1241 is a column-count mismatch. Where MySQL expects one value (the right side of IN, a subquery in the SELECT list) the subquery returned more than one column. With a row comparison like (a, b) IN (...) the message becomes Operand should contain 2 column(s).
Count the columns on both sides. The three runs below are the common cases.
01IN (SELECT id, name ...) returns two columns
WHERE customer_id IN (SELECT id, name FROM customers WHERE grade = 'A') failed with ERROR 1241 (21000): Operand should contain 1 column(s). customer_id is one column, but the subquery returned two.
The subquery only needs id. With IN (SELECT id FROM customers WHERE grade = 'A') the query returned orders 10 and 12.
Setup
CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(20), grade CHAR(1));
CREATE TABLE orders (id INT PRIMARY KEY, customer_id INT, amount INT);
INSERT INTO customers VALUES (1, 'Kim', 'A'), (2, 'Lee', 'B');
INSERT INTO orders VALUES (10, 1, 500), (11, 2, 300), (12, 1, 200);Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0SELECT id, amount FROM orders
WHERE customer_id IN (SELECT id, name FROM customers WHERE grade = 'A');ERROR 1241 (21000): Operand should contain 1 column(s)SELECT id FROM customers WHERE grade = 'A';+----+
| id |
+----+
| 1 |
+----+
1 row in set (0.00 sec)SELECT id, amount FROM orders
WHERE customer_id IN (SELECT id FROM customers WHERE grade = 'A')
ORDER BY id;+----+--------+
| id | amount |
+----+--------+
| 10 | 500 |
| 12 | 200 |
+----+--------+
2 rows in set (0.00 sec)02Subquery in the SELECT list returns two columns
A subquery used as a column value must return one column. (SELECT c.name, c.grade FROM customers c WHERE c.id = o.customer_id) AS customer raised ERROR 1241.
Two ways worked: a JOIN (FROM orders o JOIN customers c ON c.id = o.customer_id) that returns name and grade as normal columns, or two separate subqueries, one for name and one for grade. Both returned the same 3 rows.
Setup
CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(20), grade CHAR(1));
CREATE TABLE orders (id INT PRIMARY KEY, customer_id INT, amount INT);
INSERT INTO customers VALUES (1, 'Kim', 'A'), (2, 'Lee', 'B');
INSERT INTO orders VALUES (10, 1, 500), (11, 2, 300), (12, 1, 200);Query OK, 0 rows affected (0.02 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0SELECT o.id,
(SELECT c.name, c.grade FROM customers c WHERE c.id = o.customer_id) AS customer
FROM orders o;ERROR 1241 (21000): Operand should contain 1 column(s)SELECT o.id, c.name, c.grade
FROM orders o JOIN customers c ON c.id = o.customer_id
ORDER BY o.id;+----+------+-------+
| id | name | grade |
+----+------+-------+
| 10 | Kim | A |
| 11 | Lee | B |
| 12 | Kim | A |
+----+------+-------+
3 rows in set (0.00 sec)SELECT o.id,
(SELECT c.name FROM customers c WHERE c.id = o.customer_id) AS name,
(SELECT c.grade FROM customers c WHERE c.id = o.customer_id) AS grade
FROM orders o
ORDER BY o.id;+----+------+-------+
| id | name | grade |
+----+------+-------+
| 10 | Kim | A |
| 11 | Lee | B |
| 12 | Kim | A |
+----+------+-------+
3 rows in set (0.00 sec)03(a, b) IN (subquery with one column)
WHERE (item, valid_from) IN (SELECT MAX(valid_from) FROM prices GROUP BY item) failed with Operand should contain 2 column(s). The left side has two columns, so the subquery must also return two.
Adding item to the subquery (SELECT item, MAX(valid_from) ... GROUP BY item) made it work and returned the latest price per item: A1 120 and B7 300.
Setup
CREATE TABLE prices (item VARCHAR(10), valid_from DATE, price INT, PRIMARY KEY (item, valid_from));
INSERT INTO prices VALUES ('A1', '2024-01-01', 100), ('A1', '2024-03-01', 120), ('B7', '2024-01-01', 300);Query OK, 0 rows affected (0.01 sec)
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0SELECT item, valid_from, price FROM prices
WHERE (item, valid_from) IN (SELECT MAX(valid_from) FROM prices GROUP BY item);ERROR 1241 (21000): Operand should contain 2 column(s)SELECT item, MAX(valid_from) FROM prices GROUP BY item ORDER BY item;+------+-----------------+
| item | MAX(valid_from) |
+------+-----------------+
| A1 | 2024-03-01 |
| B7 | 2024-01-01 |
+------+-----------------+
2 rows in set (0.01 sec)SELECT item, valid_from, price FROM prices
WHERE (item, valid_from) IN (SELECT item, MAX(valid_from) FROM prices GROUP BY item)
ORDER BY item;+------+------------+-------+
| item | valid_from | price |
+------+------------+-------+
| A1 | 2024-03-01 | 120 |
| B7 | 2024-01-01 | 300 |
+------+------------+-------+
2 rows in set (0.00 sec)FAQ
What does Operand should contain 1 column(s) mean?
Somewhere a single value is expected, but a subquery returned two or more columns. In the runs above it was an IN subquery and a subquery in the SELECT list.
Why does the error say 2 column(s)?
The left side is a row like (item, valid_from), so MySQL expects two columns from the subquery. Our run got 2 column(s) when the subquery returned only one.
How do I get several columns from a correlated subquery?
Use a JOIN instead, or one subquery per column. Both returned the same result in the runs above.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13