【发布时间】:2018-07-26 01:21:58
【问题描述】:
如何在 JSON 列上应用 WHERE 子句以对具有两列(id Integer、attr JSON)的表执行 SELECT 查询。 JSON是嵌套的,在过滤条件下只允许一个json键值对。这个键值对可以在 Josn 中的任何位置。
+----+-----------------------------------------------------------------
| id | attr
|
+----+-----------------------------------------------------------------
| 1 | {"id":"0001","type":"donut","name":"Cake","ppu":0.55}
|
| 2 | {"id":"0002","type":"donut","name":"Cake","ppu":0.55,"batters":
{"batter1":100,"batter2":200}}
+----+-----------------------------------------------------------------
【问题讨论】:
-
您可以发布一些数据,或者您尝试过的查询吗?
-
@TimBiegeleisen 我应该能够过滤 Json 列。 FYU (select id from table_name where attr contains "batter2":200")
标签: mysql mariadb mysql-python