我有一个mysql视图启动并运行。
concat(`dp`.`fld_name`,
' ',
`mt`.`fld_model`,
' ',
`m`.`fld_diameter_nominal`) AS `fld_meter_type_info`,
现在我想做的是基本的if else声明。
if(fld_type == 1 || fld_type == 4 ) -> get rid of fld_diameter_nominal in concat
else -> same concat
如何将其放入视野?
编辑:已解决
concat(dp.fld_name,
' ',
mt.fld_model,
' ',
case when `m`.`fld_type` in (1,4)
then ''
else m.fld_diameter_nominal
end
) AS fld_meter_type_info,
感谢您的时间
答案 0 :(得分:2)
concat(dp.fld_name,
' ',
mt.fld_model,
' ',
case when fld_type in (1,4)
then ''
else m.fld_diameter_nominal
end
) AS fld_meter_type_info
答案 1 :(得分:0)
试试这个::
Select
CASE WHEN fld_type in (1,4)
THEN oncat(`dp`.`fld_name`,' ',`mt`.`fld_model`)
ELSE
concat(`dp`.`fld_name`,' ', `mt`.`fld_model`,' ', `m`.`fld_diameter_nominal`) END AS `fld_meter_type_info`