简体   繁体   English

mysql子查询错误[21000] [1241]操作数应包含1列

[英]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) [21000] [1241]操作数应包含1列

how can i fix it? 我该如何解决?

You can try below - using SELF JOIN 您可以在下面尝试-使用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 您编写子查询错了,可以通过使用join尝试如下

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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