英文:
SQL skip is value is null
问题
I have this SQL:
SELECT
JSON_VALUE(DATA, '$.name') AS name,
JSON_VALUE(DATA, '$.total') AS total,
FROM `somewhere`
It produces data such as:
Leon null
Ashlee 38
Peter null
I want to only return records where total
is not null. What do I need to adjust in my query? I know it's probably a WHERE
, but I never work with SQL so not sure what.
英文:
I have this SQL:
SELECT
JSON_VALUE(DATA, '$.name') AS name,
JSON_VALUE(DATA, '$.total') AS total,
FROM `somewhere`
It produces data such as:
Leon null
Ashlee 38
Peter null
I want to only return records where total
is not null. What do I need to adjust in my query? I know it's probably a WHERE
, but I never work with SQL so not sure what.
答案1
得分: 1
你应该将它添加到 where 子句中
并使用 IS NOT NULL 过滤器
以下是查询:
SELECT
JSON_VALUE(DATA, '$.name') AS 名称,
JSON_VALUE(DATA, '$.total') AS 总数,
FROM `某处`
WHERE
JSON_VALUE(DATA, '$.name') 不是空的
英文:
You should add it in where clause
and IS NOT NULL filter
Here is the query:
SELECT
JSON_VALUE(DATA, '$.name') AS name,
JSON_VALUE(DATA, '$.total') AS total,
FROM `somewhere`
WHERE
JSON_VALUE(DATA, '$.name') IS NOT NULL
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论