title: MySQL 5.7 with native JSON support - how to select rows where a specific value exists in array?
body: <p>I have a persons Table with a native JSON field / column called "json".
  The first row of my table has this content in the column json:</p>
  
  <pre><code>{"misc": [{"sdsd": "sdsdsd"}], "size": 178, "social": {"skype": "4455454", "myspace": "fw2121ege", "twitter": "wr4541", "facebook": "frfsfsfasfsf"}, "mobility": ["forklift_sparkle", "license_for_passenger_transport", "car", "driver_license"], "piercing": true, "shoesize": 43, "trousers": {"width": 32, "length": 32}, "haircolor": "black", "shoe_size": 43, "additional_career": [{"ddgdgdg": "dggdgddg"}], "additional_social": [{"StudiVZ": "sfsfsfsf"}], "additional_language": [{"gfggfgf": "good"}], "additional_mobility": ["sfsf"]}
  </code></pre>
  
  <p>or here well formatted:</p>
  
  <p><a href="http://www.jsoneditoronline.org/?id=bcceb2f1ec208ea23737ee32c1ccc5a3" rel="nofollow">http://www.jsoneditoronline.org/?id=bcceb2f1ec208ea23737ee32c1ccc5a3</a></p>
  
  <p>So - my question is: How can I search if the value "car" exists in the object "mobility"? </p>
  
  <p>This does not work:</p>
  
  <pre><code>SELECT * FROM `Persons` WHERE JSON_EXTRACT(`persons`.`json`,"$.mobility[*]") = 'car' 
  </code></pre>
  
  <p>(gives no result)</p>
  
  <p>Also not work:</p>
  
  <pre><code>SELECT * FROM `Persons` WHERE JSON_SEARCH(`persons`.`json`, 'all', 'car', NULL, '$.mobility[*]')
  </code></pre>
  
  <p>(gives no result)</p>
  
  <p>This (with JSON_CONTAINS) also does not work:</p>
  
  <pre><code>SELECT * FROM `Persons` WHERE JSON_CONTAINS(`persons`.`json`, 'car', "$.mobility")
  </code></pre>
  
  <p>(gives error: SELECT * FROM <code>Persons</code> WHERE JSON_CONTAINS(<code>persons</code>.<code>json</code>, 'car', "$.mobility") )</p>
  
  <p>BUT this works well:</p>
  
  <pre><code>SELECT * FROM `Persons` WHERE JSON_CONTAINS(`persons`.`json`, '178', "$.size")
  </code></pre>
  
  <p>I think it is a problem because "mobility" contains an array... but how to select if an element exists in this array "mobility" ?</p>