例如.. 我有三个 case 语句,我想将其值保存在变量中..
Select
Case when 1 then variable='123' else
case when 2 then variable='456' else
case when 3 then variable='123456'
from
table X where
some conditions ;
最佳答案
例如试试这个
Select x.field,
Case x.value
when 1 then '123'
when 2 then '456'
when 3 then '123456'
ELSE '789'
END AS variable
from
table X where
some conditions ;
关于mysql - 优化案例陈述的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29756300/