mysql的case when字段为空,null的问题
目录
- mysql的case when字段为空,null
- case when 判断null(已测试)
- 总结
mysql的case when字段为空,null
name字段为null时替换为 ‘该字段为空’
SELECT CASE WHEN name is null THEN '该字段为空' ELSE name END as name ,email_id FROM mysql_table_name
case when 判断null(已测试)
SELECT (case when cdi.DEVICE_TAG is not null then cd开发者_大数据i.DEVICE_TAG else '暂无数据' end) as deviceTag, (case when cdihttp://www.devze.com.DEVICE_CODE is notpython 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, (casepython 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
iswww.devze.com null 或者is not null
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持我们。
精彩评论