简体   繁体   English

错误 #1241 - 操作数应包含 1 列

[英]Error #1241 - Operand should contain 1 column(s)

I am trying this QUERY, and return this weird error.我正在尝试这个 QUERY,并返回这个奇怪的错误。 What does it mean?这是什么意思?

Here is my query:这是我的查询:

SELECT * FROM newRowP a WHERE a.rowId IN 
(SELECT * FROM newCellP b WHERE b.cellId IN 
(SELECT * FROM newproviderP c WHERE c.pId IN ('3000344','245')))

Your subqueries, which SELECT * , are returning more than one column;您的SELECT *子查询返回不止一列; whereas IN () requires exactly one column to be returned.IN ()需要返回一列。

There should only be one column returned from the result of a SELECT statement in a subquery.子查询中的SELECT语句的结果应该只返回一列。 eg例如

SELECT * 
FROM newRowP a 
WHERE a.rowId IN (SELECT colName FROM newCellP b .....)

but a better way of using IN is JOIN ing the tables.但使用IN的更好方法是JOIN表。

SELECT  DISTINCT a.*
FROM    newRowP a
        INNER JOIN newCellP b
            ON a.rowID = b.colName
        INNER JOIN newProviderP c
            ON b.cellID = c. colName
WHERE   c.pid IN ('3000344','245')

where colname are the columns that you want to link with other table.其中colname是要与其他表链接的列。

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

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