How can write queries in MySQL that can parse JSON data in a column?

后端 未结 3 497
庸人自扰
庸人自扰 2020-12-01 11:55

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: Wi

3条回答
  •  一向
    一向 (楼主)
    2020-12-01 12:48

    Try the following query and see if it fits your needs:

    SELECT user_id, json_data
    FROM articles
    WHERE common_schema.extract_json_value(json_data,'title')
    LIKE "%CPU%"
    

    This will only work on MySQL version 5.1 or newer.

提交回复
热议问题