gpt4 book ai didi

mysql - 在mysql查询中使用嵌套大小写条件

转载 作者:行者123 更新时间:2023-11-30 00:53:35 25 4
gpt4 key购买 nike

if(qtype==3)
column=somecolumn;
else if(qtype==2)
{
if(open==0)
column=anycolumn;
else
column =somecolumn;
}
else{
acolumn,bcolumn,ccolumn //this else----|
} |
----------------|

我想在我的 mysql 查询中实现上述嵌套的 if-else 条件。其中条件将基于其中一列。这就是我到目前为止所做的。

select qtype,open,(Case when qtype=2 then answer
Else (Case when qtype=3 then
(Case when open=0 then somecolumn
Else othercolumn End) End)

Else....//how to implement this else here)

我很困惑如何整合最后的其他部分?

谢谢

最佳答案

格式是正确的,但是与开头的 if-else 伪代码相比,您交换了 2 和 3:

select qtype,open,(Case when qtype=3 then answer
Else (Case when qtype=2 then
(Case when open=0 then somecolumn
Else othercolumn End) End))

关于mysql - 在mysql查询中使用嵌套大小写条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20772687/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com