title: how to use wildcard query json data from mysql
body: <p>I am using laravel and mysql 5.7 with json.
  Here is my json data from database.</p>
  
  <pre><code>mysql&gt; select goods from packet_code where id=582 \G
  *************************** 1. row ***************************
  goods: 
  [
   {"code": "S87719300077661", "size": "7", "loged_by": "93,xx"}, 
   {"code": "S87719300094874", "size": "9", "loged_by": "93,xx"}, 
   {"code": "S87719300112648", "size": "11", "loged_by": "93,xx"}
  ]
  1 row in set (0.05 sec)
  </code></pre>
  
  <p>I tried this query;</p>
  
  <p><code>select * from packet_code where goods-&gt;'$[0].code'="S87719300077661;"</code></p>
  
  <p>It works fine and I get a result.</p>
  
  <p><strong>But the thing is that the elements are not stored in order, it could store in second or third position.</strong></p>
  
  <p>When I try this</p>
  
  <p><code>select * from packet_code where goods-&gt;'$[*].code'="S87719300077661";</code>
  I got nothing.
  Also JSON_CONTAINS works fine:</p>
  
  <pre><code>select *  from packet_code where JSON_CONTAINS(goods,'"S87719300077661"','$[0].code');
  </code></pre>
  
  <p>But when I use wildcard </p>
  
  <pre><code> select *  from packet_code where JSON_CONTAINS(goods,'"S87719300077661"','$[*].code');
  </code></pre>
  
  <p>I got this error:</p>
  
  <p><code>In this situation, path expressions may not contain the * and ** tokens.</code></p>
  
  <p>Tried change <code>'$[0].code'</code> to <code>$[0 to last].code</code> not work either.</p>