简体   繁体   中英

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?

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;

you did wrong to write subquery you can try like below by using join

SELECT  t1.* from table_1 t1    
 join  (SELECT 
`name`, `mark`, `parent`, `description` FROM counterparty
       ) AS table_2 t2 on  t1.mark!=t2.mark

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM