简体   繁体   中英

Trying to include an “or” in a case on mysql - Error Code: 1241. Operand should contain 1 column(s)

I'm trying to include an "OR" clause in a CASE but I keep getting

"Error Code: 1241. Operand should contain 1 column(s)

Here's a sample of the query.

       select [...],
            CASE  
                when category1.Category1Name in (...) or category1.Category1Name like (...) then 'L-ACCESSORIES'
                when[...]
            end as 'Style'
       from [...]

If someone could shed some like on this it'd be much appreciated.

this syntax completely worked on mysql

SELECT OrderID, Quantity,
CASE
    WHEN Quantity like 3 or quantity like 100 THEN "The quantity is either 3 or 100"

    ELSE "The quantity is something else"
END
FROM OrderDetails;

but when i used in instead of like it didn't work so the issue is not with or it's with ==> in . each case must be closed as well

The issue is most likely coming from your like statement. It can only contain 1 value. If you write

like(1,2) 

you will get this error.

All other operations should work in mysql .

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