【发布时间】:2020-10-06 00:01:55
【问题描述】:
我正在尝试各种可能性来提取包含数组的 JSON 列中的单个元素。举个例子吧:
Database:
id | info
---------
1 |{"name": "aaa", "colors": ["a","b"]}
2 |{"name": "bbb", "colors": ["c","d"]}
3 |{"name": "ccc", "colors": ["e","f"]}
我需要的是有一个类似的查询,比如:
select name, color from info where color = a;
这应该返回:
"aaa", "a"
我卡住的问题是我无法在没有固定索引的情况下在数组中搜索,但我需要能够在没有固定索引的情况下查询数据库。
【问题讨论】:
-
在使用关系数据库系统时考虑使用关系设计。
-
这应该返回:"aaa", "a" 输出作为过滤条件的众所周知的文字
"a"有什么意义?
标签: mysql sql arrays json select