mysql查询给某个字段赋值

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 from table

原文链接:https://blog.csdn.net/wang740209668/article/details/49686249

发布了19 篇原创文章 · 获赞 19 · 访问量 6135

猜你喜欢

转载自blog.csdn.net/Lmingtian_huigenghao/article/details/104647510
今日推荐