gpt4 book ai didi

mysql - 在数据没有 key 的情况下使用 JSON 提取

转载 作者:搜寻专家 更新时间:2023-10-30 20:14:06 25 4
gpt4 key购买 nike

我的数据:

 ["2016-04-21", "2016-04-22"] 

我的查询:

select * from applications WHERE JSON_CONTAINS("date", "$");

我的 json 数据没有键,显示我如何在这里使用 JSON_CONTAINS

最佳答案

如果您想在 JSON 数据中查找日期值,可以使用 JSON_SEARCH 使用以下命令相反:

SELECT * 
FROM applications
WHERE NOT JSON_SEARCH(col_json, 'one', '2016-04-22') IS NULL;

demo on dbfiddle.uk


为什么不能使用 JSON_CONTAINS

要在 JSON 数据中搜索特定日期值,您需要使用通配符 (*)。 JSON_CONTAINS 路径参数不允许这样做:

An error occurs if target or candidate is not a valid JSON document, or if the path argument is not a valid path expression or contains a * or ** wildcard.

关于mysql - 在数据没有 key 的情况下使用 JSON 提取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54742347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com