mysql case when把0变为空字符
时间: 2023-10-12 21:05:16 浏览: 65
在MySQL中,使用CASE语句可以根据条件对字段进行不同的处理。如果你想将0变为空字符,可以在CASE语句中添加一个条件来处理。例如,你可以使用以下语法:
```
SELECT CASE
WHEN field = 0 THEN ''
ELSE field
END AS new_field
FROM table_name;
```
在这个例子中,如果字段的值为0,那么它将被替换为空字符;如果字段的值不为0,那么它将保持不变。你可以根据实际情况调整条件和替换的值。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [【mysql 】 case when 统计报表利器](https://blog.csdn.net/weixin_41979605/article/details/119577129)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [mysql case when 碰上中文字符串](https://blog.csdn.net/weixin_39858132/article/details/113126858)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文