I have a table in MySQL that has a column that store JSON objects.
How can I easily run queries that can have some of the JSON fields in the WHERE clause?
EX:
With a table named articles
+----+---------+--------------------------------------------------------------------------------------------------+
| id | user_id | json_data |
+----+---------+--------------------------------------------------------------------------------------------------+
| 1 | 1 | {"url":"https://www.cpubenchmark.net/","title": "CPU Benchmarks"} |
| 2 | 1 | {"url":"http://www.ebay.com/sch/CPUs-Processors-/164/i.html","title": "Computer and Processors"} |
| 3 | 2 | {"url":"https://www.youtube.com/watch?v=tntOCGkgt98","title": "Funny Cats Compilation" |
+----+---------+--------------------------------------------------------------------------------------------------+
I want to be able to write something like:
SELECT user_id, json_data FROM articles WHERE json_data.title LIKE "%CPU%"
That should return only the first row.
question from:
https://stackoverflow.com/questions/29137915/how-can-write-queries-in-mysql-that-can-parse-json-data-in-a-column 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…