MySQL error 1241: Operand should contain n column(s)
You can get MySQL error 1241 when your operand contains the wrong number of expected columns.
A subselect returns 3 columns, but only two are expected:
SELECT * FROM yourtable
WHERE (id, type) IN (SELECT id, type, name FROM table2)
^^ ^^^^ ^^ ^^^^ ^^^^
2 columns 3 columns
or if you are using the wrong syntax:
INSERT INTO table2 (Name, Address)
SELECT (Name, Address)
FROM table1;
(it should be just SELECT Name, Address FROM ...
)
or also this one:
SELECT id, (SELECT name, address FROM table2
WHERE table2.id=table1.id ORDER BY id LIMIT 1)
FROM table1
should be written as:
SELECT
id,
(SELECT name FROM table2 WHERE table2.id=table1.id ORDER BY id LIMIT 1),
(SELECT address FROM table2 WHERE table2.id=table1.id ORDER BY id LIMIT 1)
FROM table1