简体   繁体   中英

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

I am trying this QUERY, and return this weird error. 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; whereas IN () requires exactly one column to be returned.

There should only be one column returned from the result of a SELECT statement in a subquery. 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.

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.

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