mysql json format data query

The default table name is base_data and the json column name is json_value

  1. The value of json_value is {“ids”: [“a”, “b”], “datas”: [{“name”: “张三”}]}

    Then the query statement should be

	select * from base_data  where JSON_CONTAINS(json_value -> "$.ids", JSON_ARRAY('a'));
   	或者 
   	select * from base_data  where JSON_CONTAINS(json_value -> "$.ids[*]", JSON_ARRAY('a'));
	两种都行,具体什么区别暂时还不得而知
Published 38 original articles · praised 17 · visits 9010

Guess you like

Origin blog.csdn.net/cainiao1412/article/details/101429701