1、多个字段的判断,case 后不指定字段,使用when来判断多个字段
SELECT A.id,NAME,description, CASE WHEN ISNULL(apply_status) THEN 4 WHEN (A.enabled=0) THEN 3 ELSE apply_status END status FROM tm_vinterface A LEFT JOIN th_interface_apply_history B ON A.id = B.interface_id AND B.account_id = 1047 AND B.enabled = 1
2、单个字段的判断,case 接固定字段,按照值处理
SELECT A.id,NAME,description, CASE apply_status WHEN 0 THEN "申请中" WHEN 1 THEN "通过" ELSE "驳回" END status FROM tm_vinterface A LEFT JOIN th_interface_apply_history B ON A.id = B.interface_id AND B.account_id = 1047 AND B.enabled = 1