-2

我正在尝试使用concat_ws. 其中一个字段 ( is_logged) 仅包含值01yes如果is_logged字段的值是,我想连接1no否则。

例如 - concat_ws('', month,'-', year, ',Logged-', is_logged) info

电流输出 -Dec - 2020,Logged-1

预期输出 -Dec - 2020,Logged-Yes

如何做到这一点?谢谢!

4

2 回答 2

1

在不同的 dbms 中可能会有所不同,但您可以这样做:

select concat_ws('',month,'-',year,',Logged-',case is_logged when 1 then 'yes' else 'no' end) info
from yourtable
于 2021-04-06T18:37:51.977 回答
0

我根据这个答案得到了这个工作-

concat_ws('', month,'-', year, ',Logged-',IFNULL(ELT(FIELD(is_logged,1),'Yes'),'No')) info
于 2021-04-06T19:00:53.447 回答