title: How to query array of coordinate objects in MySQL
body: <p>I am storing OCR text detected on images using their coordinate data, where the 'bounds' field of type JSON:</p>
  <pre><code>id: 89
  image_id: 36
  text: ITALIAN
  bounds: [{&quot;x&quot;: 160, &quot;y&quot;: 51}, {&quot;x&quot;: 225, &quot;y&quot;: 50}, {&quot;x&quot;: 225, &quot;y&quot;: 63}, {&quot;x&quot;: 160, &quot;y&quot;: 64}]
  </code></pre>
  <p>The 'bounds' represent the coordinates of the box surrounding the string so that I can identify the string location on the image.
  How would I be able to query for words that are within a user defined bounding box? For example:</p>
  <pre><code>[{&quot;x&quot;: 0, &quot;y&quot;: 0}, {&quot;x&quot;: 200, &quot;y&quot;: 0}, {&quot;x&quot;: 0, &quot;y&quot;: 200}, {&quot;x&quot;: 200, &quot;y&quot;: 200}]
  </code></pre>
  <p>So far, what I have is:</p>
  <pre><code>SELECT * FROM bounding_boxes 
    where image_id = 36 
    and (JSON_EXTRACT(`bounds` , '$**.x') &gt;= 0 or JSON_EXTRACT(`bounds` , '$**.x') &lt;= 200)
    and (JSON_EXTRACT(`bounds` , '$**.y') &gt;= 0 or JSON_EXTRACT(`boundss` , '$**.y') &lt;= 200);
  </code></pre>