使用MySql Case语句的正确方法是什么

时间:2022-12-13 17:28:51

I am trying this:

我正在尝试这个:

CASE VAR_DIVISION WHEN 'C3' OR 'J4' THEN
    /* code here */
End Case

But I keep getting errors when I try to execute the procedure.

但是当我尝试执行该过程时,我不断收到错误。

2 个解决方案

#1


2  

The error is the End Case - it just needs to be end, followed by a column name - like so:

错误是结束案例 - 它只需要结束,然后是列名称 - 如下所示:

CASE VAR_DIVISION WHEN 'C3' OR 'J4' THEN
    /* code here */
End column_name

#2


1  

remove case from End case
//and add
END as column_name

#1


2  

The error is the End Case - it just needs to be end, followed by a column name - like so:

错误是结束案例 - 它只需要结束,然后是列名称 - 如下所示:

CASE VAR_DIVISION WHEN 'C3' OR 'J4' THEN
    /* code here */
End column_name

#2


1  

remove case from End case
//and add
END as column_name