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
