MySQL error operand should contain * column solution

Source: Internet
Author: User

Some content is processed using an SQL statement. MySQL reported error when executing a statement: Operand should contain 1 column

Literally, you need to have 1 columns of data.

My SQL statement is similar to this:

Update cdtable set cdcontent= ' CD is a good boy ' where ID in (

SELECT * FROM (

SELECT * from cdtable where cdtype into (1,2,3) Order BY id DESC LIMIT 100

) as CD

)

While the literal meaning of the error is missing the column, where is the column missing?

Tested and found to be wrong after adding the outermost SQL statement

After a careful look at the statement, found in the blue section of the above statement "where ID in (~ ~ ~)", the subquery used (SELECT * ~ ~) subquery to get more than one column of data records

And obviously, the condition data that the where ID in needs is a column, and that's where the problem occurs.

The solution is to change the "*" to "id" of the first-level subquery in the Where ID in (~ ~) brackets, and the sentence after the change is like:

Update cdtable set cdcontent= ' CD is a good boy ' where ID in (

Select ID from (

SELECT * from cdtable where cdtype into (1,2,3) Order BY id DESC LIMIT 100

) as CD

)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.