sql - How to check if BOTH valus are null
问题描述
I have table A
lets say it has 2 columns where the values can either be null or a number. I want to select only rows that have at least one of the columns not null:
x1 x2
NULL NULL (don't include)
6 NULL (include)
NULL 6 (include)
6 6 (include)
解决方案
You can use coalesce()
where coalesce(col1,col2) is not null
推荐阅读
- sql - 当子数据表值为空时返回记录
- c++ - 托盘图标应用程序将从服务中关闭
- android - OnCreateOptionMenu 不适用于 Theme.Material.Light.Dialog 主题
- r - 获取列表中函数的名称
- javascript - 无法在纸张列表框上触发铁选择事件
- c# - 将文件上传到 WebApi 并保存,在 IE 中有效,但在 Chrome 中无效
- git - git commit 不适用于 Git Bash
- javascript - 如何从 Firebase 获取 PWA 数据
- angular - 如何在运行时更改 Angular Material Datepicker 格式
- python - python tkinter Radiobuttons - 在显示之前选择两个按钮