Skip to content
Advertisement

mysql subquery ERROR [21000][1241] Operand should contain 1 column(s)

I have a table called counterparty. I’m going to have a query on this table Something like this:

SELECT (`name`, `mark`, `parent`, `description`) AS table_1 FROM (SELECT 
`name`, `mark`, `parent`, `description` FROM counterparty) AS table_2 WHERE 
(table_1.mark <> table_2.parent);

But the error below shows:

[21000][1241] Operand should contain 1 column(s)

how can i fix it?

Advertisement

Answer

You can try below – using SELF JOIN

SELECT table_1 .`name`, table_1.`mark`, table_1.`parent`, table_1 .`description` 
FROM counterparty table_1 inner join counterparty table_2 
table_1.mark <> table_2.parent;
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement