<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="spatial-relation-functions-mbr">
      </a>
      14.16.9.2 Spatial Relation Functions That Use Minimum Bounding Rectangles
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045196393744">
  </a>
  <a class="indexterm" name="idm46045196392704">
  </a>
  <p>
   MySQL provides several MySQL-specific functions that test the
        relationship between minimum bounding rectangles (MBRs) of two
        geometries
   <em class="replaceable">
    <code>
     g1
    </code>
   </em>
   and
   <em class="replaceable">
    <code>
     g2
    </code>
   </em>
   . The return values 1 and 0
        indicate true and false, respectively.
  </p>
  <p>
   The bounding box of a point is interpreted as a point that is
        both boundary and interior.
  </p>
  <p>
   The bounding box of a straight horizontal or vertical line is
        interpreted as a line where the interior of the line is also
        boundary. The endpoints are boundary points.
  </p>
  <p>
   If any of the parameters are geometry collections, the interior,
        boundary, and exterior of those parameters are those of the
        union of all elements in the collection.
  </p>
  <p>
   Functions in this section detect arguments in either Cartesian
        or geographic spatial reference systems (SRSs), and return
        results appropriate to the SRS.
  </p>
  <p>
   Unless otherwise specified, functions in this section handle
        their geometry arguments as follows:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      If any argument is
      <code class="literal">
       NULL
      </code>
      or an empty
            geometry, the return value is
      <code class="literal">
       NULL
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If any geometry argument is not a syntactically well-formed
            geometry, an
      <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_gis_invalid_data" target="_top">
       <code class="literal">
        ER_GIS_INVALID_DATA
       </code>
      </a>
      error
            occurs.
     </p>
    </li>
    <li class="listitem">
     <p>
      If any geometry argument is a syntactically well-formed
            geometry in an undefined spatial reference system (SRS), an
      <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_srs_not_found" target="_top">
       <code class="literal">
        ER_SRS_NOT_FOUND
       </code>
      </a>
      error
            occurs.
     </p>
    </li>
    <li class="listitem">
     <p>
      For functions that take multiple geometry arguments, if
            those arguments are not in the same SRS, an
      <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_gis_different_srids" target="_top">
       <code class="literal">
        ER_GIS_DIFFERENT_SRIDS
       </code>
      </a>
      error
            occurs.
     </p>
    </li>
    <li class="listitem">
     <p>
      If any argument is geometrically invalid, either the result
            is true or false (it is undefined which), or an error
            occurs.
     </p>
    </li>
    <li class="listitem">
     <p>
      For geographic SRS geometry arguments, if any argument has a
            longitude or latitude that is out of range, an error occurs:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         If a longitude value is not in the range (−180,
                180], an
         <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_geometry_param_longitude_out_of_range" target="_top">
          <code class="literal">
           ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE
          </code>
         </a>
         error occurs.
        </p>
       </li>
       <li class="listitem">
        <p>
         If a latitude value is not in the range [−90, 90],
                an
         <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_geometry_param_latitude_out_of_range" target="_top">
          <code class="literal">
           ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE
          </code>
         </a>
         error occurs.
        </p>
       </li>
      </ul>
     </div>
     <p>
      Ranges shown are in degrees. If an SRS uses another unit,
            the range uses the corresponding values in its unit. The
            exact range limits deviate slightly due to floating-point
            arithmetic.
     </p>
    </li>
    <li class="listitem">
     <p>
      Otherwise, the return value is non-
      <code class="literal">
       NULL
      </code>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   These MBR functions are available for testing geometry
        relationships:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <a name="function_mbrcontains">
     </a>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrcontains">
       <code class="literal">
        MBRContains(
        <em class="replaceable">
         <code>
          g1
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          g2
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045196362592">
     </a>
     <p>
      Returns 1 or 0 to indicate whether the minimum bounding
            rectangle of
      <em class="replaceable">
       <code>
        g1
       </code>
      </em>
      contains the
            minimum bounding rectangle of
      <em class="replaceable">
       <code>
        g2
       </code>
      </em>
      .
            This tests the opposite relationship as
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrwithin">
       <code class="literal">
        MBRWithin()
       </code>
      </a>
      .
     </p>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrcontains">
       <code class="literal">
        MBRContains()
       </code>
      </a>
      handles its
            arguments as described in the introduction to this section.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa23967878"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@g1</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'Polygon((0 0,0 3,3 3,3 0,0 0))'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@g2</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'Point(1 1)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">MBRContains</span><span class="token punctuation">(</span><span class="token variable">@g1</span><span class="token punctuation">,</span><span class="token variable">@g2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">MBRWithin</span><span class="token punctuation">(</span><span class="token variable">@g2</span><span class="token punctuation">,</span><span class="token variable">@g1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> MBRContains(@g1,@g2) <span class="token punctuation">|</span> MBRWithin(@g2,@g1) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>                    1 <span class="token punctuation">|</span>                  1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_mbrcoveredby">
     </a>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrcoveredby">
       <code class="literal">
        MBRCoveredBy(
        <em class="replaceable">
         <code>
          g1
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          g2
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045196347472">
     </a>
     <p>
      Returns 1 or 0 to indicate whether the minimum bounding
            rectangle of
      <em class="replaceable">
       <code>
        g1
       </code>
      </em>
      is covered by the
            minimum bounding rectangle of
      <em class="replaceable">
       <code>
        g2
       </code>
      </em>
      .
            This tests the opposite relationship as
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrcovers">
       <code class="literal">
        MBRCovers()
       </code>
      </a>
      .
     </p>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrcoveredby">
       <code class="literal">
        MBRCoveredBy()
       </code>
      </a>
      handles its
            arguments as described in the introduction to this section.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa33485396"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@g1</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'Polygon((0 0,0 3,3 3,3 0,0 0))'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@g2</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'Point(1 1)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">MBRCovers</span><span class="token punctuation">(</span><span class="token variable">@g1</span><span class="token punctuation">,</span><span class="token variable">@g2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">MBRCoveredby</span><span class="token punctuation">(</span><span class="token variable">@g1</span><span class="token punctuation">,</span><span class="token variable">@g2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> MBRCovers(@g1,@g2) <span class="token punctuation">|</span> MBRCoveredby(@g1,@g2) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>                  1 <span class="token punctuation">|</span>                     0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">MBRCovers</span><span class="token punctuation">(</span><span class="token variable">@g2</span><span class="token punctuation">,</span><span class="token variable">@g1</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">MBRCoveredby</span><span class="token punctuation">(</span><span class="token variable">@g2</span><span class="token punctuation">,</span><span class="token variable">@g1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> MBRCovers(@g2,@g1) <span class="token punctuation">|</span> MBRCoveredby(@g2,@g1) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>                  0 <span class="token punctuation">|</span>                     1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_mbrcovers">
     </a>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrcovers">
       <code class="literal">
        MBRCovers(
        <em class="replaceable">
         <code>
          g1
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          g2
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045196331120">
     </a>
     <p>
      Returns 1 or 0 to indicate whether the minimum bounding
            rectangle of
      <em class="replaceable">
       <code>
        g1
       </code>
      </em>
      covers the
            minimum bounding rectangle of
      <em class="replaceable">
       <code>
        g2
       </code>
      </em>
      .
            This tests the opposite relationship as
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrcoveredby">
       <code class="literal">
        MBRCoveredBy()
       </code>
      </a>
      . See the
            description of
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrcoveredby">
       <code class="literal">
        MBRCoveredBy()
       </code>
      </a>
      for examples.
     </p>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrcovers">
       <code class="literal">
        MBRCovers()
       </code>
      </a>
      handles its
            arguments as described in the introduction to this section.
     </p>
    </li>
    <li class="listitem">
     <a name="function_mbrdisjoint">
     </a>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrdisjoint">
       <code class="literal">
        MBRDisjoint(
        <em class="replaceable">
         <code>
          g1
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          g2
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045196318688">
     </a>
     <p>
      Returns 1 or 0 to indicate whether the minimum bounding
            rectangles of the two geometries
      <em class="replaceable">
       <code>
        g1
       </code>
      </em>
      and
      <em class="replaceable">
       <code>
        g2
       </code>
      </em>
      are disjoint (do not
            intersect).
     </p>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrdisjoint">
       <code class="literal">
        MBRDisjoint()
       </code>
      </a>
      handles its
            arguments as described in the introduction to this section.
     </p>
    </li>
    <li class="listitem">
     <a name="function_mbrequals">
     </a>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrequals">
       <code class="literal">
        MBREquals(
        <em class="replaceable">
         <code>
          g1
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          g2
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045196308752">
     </a>
     <p>
      Returns 1 or 0 to indicate whether the minimum bounding
            rectangles of the two geometries
      <em class="replaceable">
       <code>
        g1
       </code>
      </em>
      and
      <em class="replaceable">
       <code>
        g2
       </code>
      </em>
      are the same.
     </p>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrequals">
       <code class="literal">
        MBREquals()
       </code>
      </a>
      handles its
            arguments as described in the introduction to this section,
            except that it does not return
      <code class="literal">
       NULL
      </code>
      for
            empty geometry arguments.
     </p>
    </li>
    <li class="listitem">
     <a name="function_mbrintersects">
     </a>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrintersects">
       <code class="literal">
        MBRIntersects(
        <em class="replaceable">
         <code>
          g1
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          g2
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045196298064">
     </a>
     <p>
      Returns 1 or 0 to indicate whether the minimum bounding
            rectangles of the two geometries
      <em class="replaceable">
       <code>
        g1
       </code>
      </em>
      and
      <em class="replaceable">
       <code>
        g2
       </code>
      </em>
      intersect.
     </p>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrintersects">
       <code class="literal">
        MBRIntersects()
       </code>
      </a>
      handles its
            arguments as described in the introduction to this section.
     </p>
    </li>
    <li class="listitem">
     <a name="function_mbroverlaps">
     </a>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbroverlaps">
       <code class="literal">
        MBROverlaps(
        <em class="replaceable">
         <code>
          g1
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          g2
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045196288176">
     </a>
     <p>
      Two geometries
      <span class="emphasis">
       <em>
        spatially overlap
       </em>
      </span>
      if
            they intersect and their intersection results in a geometry
            of the same dimension but not equal to either of the given
            geometries.
     </p>
     <p>
      This function returns 1 or 0 to indicate whether the minimum
            bounding rectangles of the two geometries
      <em class="replaceable">
       <code>
        g1
       </code>
      </em>
      and
      <em class="replaceable">
       <code>
        g2
       </code>
      </em>
      overlap.
     </p>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbroverlaps">
       <code class="literal">
        MBROverlaps()
       </code>
      </a>
      handles its
            arguments as described in the introduction to this section.
     </p>
    </li>
    <li class="listitem">
     <a name="function_mbrtouches">
     </a>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrtouches">
       <code class="literal">
        MBRTouches(
        <em class="replaceable">
         <code>
          g1
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          g2
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045196277232">
     </a>
     <p>
      Two geometries
      <span class="emphasis">
       <em>
        spatially touch
       </em>
      </span>
      if their
            interiors do not intersect, but the boundary of one of the
            geometries intersects either the boundary or the interior of
            the other.
     </p>
     <p>
      This function returns 1 or 0 to indicate whether the minimum
            bounding rectangles of the two geometries
      <em class="replaceable">
       <code>
        g1
       </code>
      </em>
      and
      <em class="replaceable">
       <code>
        g2
       </code>
      </em>
      touch.
     </p>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrtouches">
       <code class="literal">
        MBRTouches()
       </code>
      </a>
      handles its
            arguments as described in the introduction to this section.
     </p>
    </li>
    <li class="listitem">
     <a name="function_mbrwithin">
     </a>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrwithin">
       <code class="literal">
        MBRWithin(
        <em class="replaceable">
         <code>
          g1
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          g2
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045196266336">
     </a>
     <p>
      Returns 1 or 0 to indicate whether the minimum bounding
            rectangle of
      <em class="replaceable">
       <code>
        g1
       </code>
      </em>
      is within the
            minimum bounding rectangle of
      <em class="replaceable">
       <code>
        g2
       </code>
      </em>
      .
            This tests the opposite relationship as
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrcontains">
       <code class="literal">
        MBRContains()
       </code>
      </a>
      .
     </p>
     <p>
      <a class="link" href="spatial-relation-functions-mbr.html#function_mbrwithin">
       <code class="literal">
        MBRWithin()
       </code>
      </a>
      handles its
            arguments as described in the introduction to this section.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa10484403"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@g1</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'Polygon((0 0,0 3,3 3,3 0,0 0))'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@g2</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'Polygon((0 0,0 5,5 5,5 0,0 0))'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">MBRWithin</span><span class="token punctuation">(</span><span class="token variable">@g1</span><span class="token punctuation">,</span><span class="token variable">@g2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">MBRWithin</span><span class="token punctuation">(</span><span class="token variable">@g2</span><span class="token punctuation">,</span><span class="token variable">@g1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> MBRWithin(@g1,@g2) <span class="token punctuation">|</span> MBRWithin(@g2,@g1) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>                  1 <span class="token punctuation">|</span>                  0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
     </div>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
