title: MariaDB JSON Functions with Arrays
body: <p>I have JSON arrays stored as strings in a MariaDB table. I want to return the rows when certain key-values are present anywhere in the array. </p>
  
  <p>I performed the following test....</p>
  
  <pre><code>set @json='[{"name":"Albert","state":"IL"},{"name":"John","state":"CA"}]'
  </code></pre>
  
  <p>Executed the following query ...</p>
  
  <pre><code>select json_value(@json,'$[0].name')='Albert'
  </code></pre>
  
  <p>It got me the desired result which is...</p>
  
  <pre><code>1
  </code></pre>
  
  <p>Even the following query also gave me the same result(may be '*' is treated as the first element)...</p>
  
  <pre><code>select json_value(@json,'$[*].name')='Albert'
  </code></pre>
  
  <p>But when I provide the second name("John") in the condition, I do not get any result...</p>
  
  <pre><code>select json_value(@json,'$[*].name')='John'
  </code></pre>
  
  <p>Result... </p>
  
  <pre><code>0
  </code></pre>
  
  <p>So my observation is that when we provide the array index the "json_value" function is able to return the desired result.</p>
  
  <p>Is there a way where I can avoid specifying the array index and search the desired key-value?</p>