sql语句ifnull用法
时间: 2023-08-24 12:10:32 浏览: 129
Mysql常用sql语句汇总
IFNULL函数用于判断第一个表达式是否为NULL,如果为NULL则返回第二个参数的值,如果不为NULL则返回第一个参数的值。\[2\]在你的例子中,你想要查询tcc表中的total_score值,如果该值为NULL,则返回0,否则返回该值。你的写法是正确的,可以使用以下SQL语句实现你的需求:
SELECT IFNULL(tcc.TOTAL_SCORE, 0) FROM t_customer_comments tcc WHERE tcc.ORDER_ID = '73801026325011164' AND tcc.USE_FLAG = 0。\[1\]这样,如果total_score为NULL,查询结果将返回0,否则返回total_score的值。
#### 引用[.reference_title]
- *1* [SQL --ifnull的使用](https://blog.csdn.net/weixin_34006468/article/details/92218384)[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^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [SQL IFNULL()函数详细解析](https://blog.csdn.net/weixin_47343544/article/details/119876890)[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^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [SQL中的IFNULL( )函数使用和注意问题](https://blog.csdn.net/ZZQHELLO2018/article/details/94163804)[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^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文