sql - 即使在 where in 子句中的条件为空,如何返回结果集
问题描述
我正在尝试将多个 where-in 子句链接在一起,并且当其中一个返回时遇到问题null
。
如果 where in 产生 anull
我想忽略它。
declare @json nvarchar(max) = '
[
{
"key": "A",
"value": ["1","2"]
}, {
"key": "B"
}, , {
"key": "C"
}
]';
select *
from someTable]
where col1 in (select value from openjson(@json, '$[0].value'))
and col2 in (select value from openjson(@json, '$[0].value')) -- returns null, so empties query
and col3 in (select value from openjson(@json, '$[1].value')) -- returns null, so empties query
where
当集合为空时,我将如何从结果集中省略?
解决方案
推荐阅读
- html - 物化模态不工作,保持开放
- vue.js - Vue.js - 如何使用元素菜单下拉菜单
- r - dplyr 中的子选择
- maven - 如何在 bazel 中使用/导入 Flink 的 TestHarness 类?
- python - 用 python、selenium(WebDriver) 和漂亮的肥皂抓取艺术家的名字
- java - 如何使 JFrame 和 JMenubar 不在 public static void main(String[] args)
- r - 更改 ggplot2 中特定数据的颜色
- python - 在 Django 中为其创建应用程序后未出现消息
- json - 在 Swift 中从同一个 URL 获取两个 JSON
- java - Firebase Firestore 更新字段后 Android 片段崩溃