mysql - 如何从SQL中的字符串中提取项目列表
问题描述
我想将 itemid 拆分为一个列表,因为我想将该列表用作另一个查询中的条件:
data
--------------------------------------------------------------------------------
[{"shopid":64522541,"itemid":1260324852},{"shopid":31863766,"itemid":1265550228}]
我试过这样的 JSON_EXTRACT:
SELECT JSON_EXTRACT(data,'$.itemid') from table
WHERE collection_id = 88888
但它不起作用。您能否提供一种方法来提取我可以在以下代码中使用的列表:
Select id in table2
where id in LIST
解决方案
对于以下查询的 postgrey 可能会有所帮助
select (d->>'itemid')::numeric itemid
from
json_array_elements(data::json) d
推荐阅读
- java - 辅助类是否应该实现接口
- azure - Azure Application Insights 中没有异常或堆栈跟踪
- excel - 在选择查询中使用函数将结果存储在 Excel 工作表中
- pyarrow - Pyarrow 非旧版 Parquet 数据集能否读取和写入 Azure Blob?(遗留系统和 Dask 能够)
- java - 获取有条件地加入休眠或将实体设计更改为有条件地获取子项?
- python - 如何使用 Consul Agent CLI 创建新的 KV 条目,但前提是它们尚不存在?
- r - 在 R 中使用 min-max 变换时更好地处理 0?
- multithreading - 在并行化循环中正确使用 private 和 firstprivate (intel fortran)
- openstack - Microstack 托管实例中没有可用的互联网
- regex-greedy - 排除资产正则表达式