name字段为null时替换为 ‘该字段为空’
SELECT
CASE
WHEN name is null THEN '该字段为空'
ELSE name
END as name
,email_id
FROM mysql_table_name
SELECT
(case when cdi.DEVICE_TAG is not null then cdi.DEVICE_TAG else '暂无数据' end) as deviceTag,
(case when cdi.DEVICE_CODE is not null then cdi.DEVICE_CODE else '暂无数据' end) as deviceCode,
(case when sc.full_name is not null then sc.full_name else '暂无数据' end) as deviceVendor,
(case when ct.CLASS_NAME is not null then ct.CLASS_NAME else '暂无数据' end) as deviceTypeNameB,
(case when cdi.DEVICE_PORT is not null then cdi.DEVICE_PORT else '暂无数据' end) as devicePort,
(case when cdi.CREATE_TIME is not null then cdi.CREATE_TIME else '暂无数据' end) as createTimeStr
-- cdi.DEVICE_TAG as deviceTag,
-- cdi.DEVICE_CODE as deviceCode,
-- sc.full_name as deviceVendor,
-- ct.CLASS_NAME as deviceTypeNameB,
-- cdi.DEVICE_PORT as devicePort,
-- cdi.CREATE_TIME as createTimeStr
FROM
con_device_info AS cdi
LEFT JOIN sys_code AS sc ON sc.code_value = cdi.DEVICE_VENDOR
LEFT join con_type as ct on ct.ID=cdi.DEVICE_TYPE
where cdi.ID=#{id}
重点:
case when xxx
is null 或者is not null