我在 mysql 中有这个查询:
SELECT col1, col2, coletc, IF(a.status_working == 'normal', a.status_working == 'NN' AND a.status_working == 'overtime', a.status_working == 'OT') as status_working
我的整个查询:
HIDDEN for security reasons.
MYSQL 返回一个错误。我需要设置三个条件 if status_working = 'normal' 然后写入输出 NN, if status_working == 'overtime' 然后写入输出OT,如果 status_working == 'overtime_s' 则写入输出>OTS
我不太擅长mysql,所以有人可以帮助我吗?
谢谢。
最佳答案
用例
SELECT col1, col2, coletc,
CASE status_working
when 'normal' then 'NN'
when 'overtime' then 'OT'
when 'overtime_s' then 'OTS'
END as status_working
From your_table
关于MYSQL SELECT IF 语句与 AND,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43398479/