mysql 查询判断空值
select A.return_car_area, case when A.return_car_area='' THEN 0 ELSE 1 END from t_base_Bq_branch A
select A.return_car_area, case A.return_car_area when '' THEN 0 ELSE 1 END from t_base_Bq_branch A
当这个字段return_car_area为空串的时候显示 0 否则显示1 case when 字段=条件 then 赋值 else 赋值 end
select IFNULL(b.tobranchID,9999) from t_base_task b
当tobranchID为null时显示 9999 否则显示数据库值 IFNULL(字段,赋值) 当字段为空是赋值
IFNULL(
CASE c.tasktype
WHEN 0 THEN (SELECT bpl.name FROM t_base_Bq_branch bpl WHERE c.stationId = bpl.rail_id )
WHEN 1 THEN (SELECT bpl.name FROM t_base_Bq_branch bpl WHERE c.stationId = bpl.rail_id ) ELSE '' END ,'') toPark