您的位置:首页 > 数据库 > MySQL

mysql sql语句查询时给某个空字段赋值case ... when ...

2015-11-06 18:13 901 查看
select case field 
when '' then '指定一个值'
when '未知'then '指定一个值'else field end
from  table 
这种方式遇到null时就不太好使了  当遇到值为null 的情况时这样用
select case when field ='' then '指定一个值' when field is null then '指定一个值' 
 else field end 

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: