<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="comparison-operators">
      </a>
      14.4.2 Comparison Functions and Operators
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045207529744">
  </a>
  <div class="table">
   <a name="idm46045207528704">
   </a>
   <p class="title">
    <b>
     Table 14.4 Comparison Operators
    </b>
   </p>
   <div class="table-contents">
    <table frame="box" rules="all" summary="A reference that lists comparison operators.">
     <colgroup>
      <col style="width: 28%"/>
      <col style="width: 71%"/>
     </colgroup>
     <thead>
      <tr>
       <th>
        Name
       </th>
       <th>
        Description
       </th>
      </tr>
     </thead>
     <tbody>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_greater-than">
         <code class="literal">
          &gt;
         </code>
        </a>
       </td>
       <td>
        Greater than operator
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_greater-than-or-equal">
         <code class="literal">
          &gt;=
         </code>
        </a>
       </td>
       <td>
        Greater than or equal operator
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_less-than">
         <code class="literal">
          &lt;
         </code>
        </a>
       </td>
       <td>
        Less than operator
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_not-equal">
         <code class="literal">
          &lt;&gt;
         </code>
         ,
         <code class="literal">
          !=
         </code>
        </a>
       </td>
       <td>
        Not equal operator
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_less-than-or-equal">
         <code class="literal">
          &lt;=
         </code>
        </a>
       </td>
       <td>
        Less than or equal operator
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_equal-to">
         <code class="literal">
          &lt;=&gt;
         </code>
        </a>
       </td>
       <td>
        NULL-safe equal to operator
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_equal">
         <code class="literal">
          =
         </code>
        </a>
       </td>
       <td>
        Equal operator
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_between">
         <code class="literal">
          BETWEEN ... AND ...
         </code>
        </a>
       </td>
       <td>
        Whether a value is within a range of values
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#function_coalesce">
         <code class="literal">
          COALESCE()
         </code>
        </a>
       </td>
       <td>
        Return the first non-NULL argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_exists">
         <code class="literal">
          EXISTS()
         </code>
        </a>
       </td>
       <td>
        Whether the result of a query contains any rows
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#function_greatest">
         <code class="literal">
          GREATEST()
         </code>
        </a>
       </td>
       <td>
        Return the largest argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_in">
         <code class="literal">
          IN()
         </code>
        </a>
       </td>
       <td>
        Whether a value is within a set of values
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#function_interval">
         <code class="literal">
          INTERVAL()
         </code>
        </a>
       </td>
       <td>
        Return the index of the argument that is less than the first
      argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_is">
         <code class="literal">
          IS
         </code>
        </a>
       </td>
       <td>
        Test a value against a boolean
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_is-not">
         <code class="literal">
          IS NOT
         </code>
        </a>
       </td>
       <td>
        Test a value against a boolean
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_is-not-null">
         <code class="literal">
          IS NOT NULL
         </code>
        </a>
       </td>
       <td>
        NOT NULL value test
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_is-null">
         <code class="literal">
          IS NULL
         </code>
        </a>
       </td>
       <td>
        NULL value test
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#function_isnull">
         <code class="literal">
          ISNULL()
         </code>
        </a>
       </td>
       <td>
        Test whether the argument is NULL
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#function_least">
         <code class="literal">
          LEAST()
         </code>
        </a>
       </td>
       <td>
        Return the smallest argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="string-comparison-functions.html#operator_like">
         <code class="literal">
          LIKE
         </code>
        </a>
       </td>
       <td>
        Simple pattern matching
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_not-between">
         <code class="literal">
          NOT BETWEEN ... AND ...
         </code>
        </a>
       </td>
       <td>
        Whether a value is not within a range of values
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_not-exists">
         <code class="literal">
          NOT EXISTS()
         </code>
        </a>
       </td>
       <td>
        Whether the result of a query contains no rows
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="comparison-operators.html#operator_not-in">
         <code class="literal">
          NOT IN()
         </code>
        </a>
       </td>
       <td>
        Whether a value is not within a set of values
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="string-comparison-functions.html#operator_not-like">
         <code class="literal">
          NOT LIKE
         </code>
        </a>
       </td>
       <td>
        Negation of simple pattern matching
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="string-comparison-functions.html#function_strcmp">
         <code class="literal">
          STRCMP()
         </code>
        </a>
       </td>
       <td>
        Compare two strings
       </td>
      </tr>
     </tbody>
    </table>
   </div>
   <div class="table-contents">
    <table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 693px;">
     <thead>
      <tr>
       <th style="width: 195.828px;">
        Name
       </th>
       <th style="width: 496.625px;">
        Description
       </th>
      </tr>
     </thead>
    </table>
   </div>
  </div>
  <br class="table-break"/>
  <a class="indexterm" name="idm46045207446576">
  </a>
  <a class="indexterm" name="idm46045207445504">
  </a>
  <p>
   Comparison operations result in a value of
   <code class="literal">
    1
   </code>
   (
   <code class="literal">
    TRUE
   </code>
   ),
   <code class="literal">
    0
   </code>
   (
   <code class="literal">
    FALSE
   </code>
   ), or
   <code class="literal">
    NULL
   </code>
   . These
        operations work for both numbers and strings. Strings are
        automatically converted to numbers and numbers to strings as
        necessary.
  </p>
  <p>
   The following relational comparison operators can be used to
        compare not only scalar operands, but row operands:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa70936420"><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 operator">=</span>  <span class="token operator">&gt;</span>  <span class="token operator">&lt;</span>  <span class="token operator">&gt;=</span>  <span class="token operator">&lt;=</span>  <span class="token operator">&lt;&gt;</span>  <span class="token operator">!=</span></code></pre>
  </div>
  <p>
   The descriptions for those operators later in this section
        detail how they work with row operands. For additional examples
        of row comparisons in the context of row subqueries, see
   <a class="xref" href="row-subqueries.html" title="15.2.15.5 Row Subqueries">
    Section 15.2.15.5, “Row Subqueries”
   </a>
   .
  </p>
  <p>
   Some of the functions in this section return values other than
   <code class="literal">
    1
   </code>
   (
   <code class="literal">
    TRUE
   </code>
   ),
   <code class="literal">
    0
   </code>
   (
   <code class="literal">
    FALSE
   </code>
   ), or
   <code class="literal">
    NULL
   </code>
   .
   <a class="link" href="comparison-operators.html#function_least">
    <code class="literal">
     LEAST()
    </code>
   </a>
   and
   <a class="link" href="comparison-operators.html#function_greatest">
    <code class="literal">
     GREATEST()
    </code>
   </a>
   are examples of
        such functions;
   <a class="xref" href="type-conversion.html" title="14.3 Type Conversion in Expression Evaluation">
    Section 14.3, “Type Conversion in Expression Evaluation”
   </a>
   , describes the
        rules for comparison operations performed by these and similar
        functions for determining their return values.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    In previous versions of MySQL, when evaluating an expression
          containing
    <code class="literal">
     LEAST()
    </code>
    or
    <code class="literal">
     GREATEST()
    </code>
    , the server attempted to guess
          the context in which the function was used, and to coerce the
          function's arguments to the data type of the expression
          as a whole. For example, the arguments to
    <code class="literal">
     LEAST("11",
          "45", "2")
    </code>
    are evaluated and sorted as strings, so
          that this expression returns
    <code class="literal">
     "11"
    </code>
    .
   </p>
   <p>
    The function is executed using the arguments as provided,
          performing data type conversions to one or more of the
          arguments if and only if they are not all of the same type.
          Any type coercion mandated by an expression that makes use of
          the return value is now performed following function
          execution. This means that
    <code class="literal">
     LEAST("11", "45", "2") +
          0
    </code>
    evaluates to
    <code class="literal">
     "11" + 0
    </code>
    and thus
          to integer 11.
   </p>
  </div>
  <p>
   To convert a value to a specific type for comparison purposes,
        you can use the
   <a class="link" href="cast-functions.html#function_cast">
    <code class="literal">
     CAST()
    </code>
   </a>
   function.
        String values can be converted to a different character set
        using
   <a class="link" href="cast-functions.html#function_convert">
    <code class="literal">
     CONVERT()
    </code>
   </a>
   . See
   <a class="xref" href="cast-functions.html" title="14.10 Cast Functions and Operators">
    Section 14.10, “Cast Functions and Operators”
   </a>
   .
  </p>
  <p>
   By default, string comparisons are not case-sensitive and use
        the current character set. The default is
   <code class="literal">
    utf8mb4
   </code>
   .
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <a name="operator_equal">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_equal">
       <code class="literal">
        =
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207414432">
     </a>
     <a class="indexterm" name="idm46045207413360">
     </a>
     <p>
      Equal:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa16263438"><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">SELECT</span> <span class="token number">1</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token string">'0'</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token string">'0.0'</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token string">'0.01'</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token string">'.01'</span> <span class="token operator">=</span> <span class="token number">0.01</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span></code></pre>
     </div>
     <p>
      For row comparisons,
      <code class="literal">
       (a, b) = (x, y)
      </code>
      is
            equivalent to:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa23036238"><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 punctuation">(</span>a <span class="token operator">=</span> x<span class="token punctuation">)</span> <span class="token operator">AND</span> <span class="token punctuation">(</span>b <span class="token operator">=</span> y<span class="token punctuation">)</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_equal-to">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_equal-to">
       <code class="literal">
        &lt;=&gt;
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207399728">
     </a>
     <a class="indexterm" name="idm46045207398240">
     </a>
     <p>
      <code class="literal">
       NULL
      </code>
      -safe equal. This operator performs
            an equality comparison like the
      <a class="link" href="comparison-operators.html#operator_equal">
       <code class="literal">
        =
       </code>
      </a>
      operator,
            but returns
      <code class="literal">
       1
      </code>
      rather than
      <code class="literal">
       NULL
      </code>
      if both operands are
      <code class="literal">
       NULL
      </code>
      , and
      <code class="literal">
       0
      </code>
      rather
            than
      <code class="literal">
       NULL
      </code>
      if one operand is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <a class="indexterm" name="idm46045207389376">
     </a>
     <p>
      The
      <a class="link" href="comparison-operators.html#operator_equal-to">
       <code class="literal">
        &lt;=&gt;
       </code>
      </a>
      operator is equivalent to the standard SQL
      <code class="literal">
       IS NOT
            DISTINCT FROM
      </code>
      operator.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa64192829"><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">SELECT</span> <span class="token number">1</span> <span class="token operator">&lt;=&gt;</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token boolean">NULL</span> <span class="token operator">&lt;=&gt;</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span> <span class="token number">1</span> <span class="token operator">&lt;=&gt;</span> <span class="token boolean">NULL</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token number">1</span> <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token boolean">NULL</span> <span class="token operator">=</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span> <span class="token number">1</span> <span class="token operator">=</span> <span class="token boolean">NULL</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span> <span class="token boolean">NULL</span></code></pre>
     </div>
     <p>
      For row comparisons,
      <code class="literal">
       (a, b) &lt;=&gt; (x,
            y)
      </code>
      is equivalent to:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa46756088"><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 punctuation">(</span>a <span class="token operator">&lt;=&gt;</span> x<span class="token punctuation">)</span> <span class="token operator">AND</span> <span class="token punctuation">(</span>b <span class="token operator">&lt;=&gt;</span> y<span class="token punctuation">)</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_not-equal">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_not-equal">
       <code class="literal">
        &lt;&gt;
       </code>
      </a>
      ,
      <a class="link" href="comparison-operators.html#operator_not-equal">
       <code class="literal">
        !=
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207374448">
     </a>
     <a class="indexterm" name="idm46045207373360">
     </a>
     <a class="indexterm" name="idm46045207372272">
     </a>
     <a class="indexterm" name="idm46045207371200">
     </a>
     <p>
      Not equal:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa68292195"><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">SELECT</span> <span class="token string">'.01'</span> <span class="token operator">&lt;&gt;</span> <span class="token string">'0.01'</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token punctuation">.</span><span class="token number">01</span> <span class="token operator">&lt;&gt;</span> <span class="token string">'0.01'</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token string">'zapp'</span> <span class="token operator">&lt;&gt;</span> <span class="token string">'zappp'</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span></code></pre>
     </div>
     <p>
      For row comparisons,
      <code class="literal">
       (a, b) &lt;&gt; (x,
            y)
      </code>
      and
      <code class="literal">
       (a, b) != (x, y)
      </code>
      are
            equivalent to:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa47026916"><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 punctuation">(</span>a <span class="token operator">&lt;&gt;</span> x<span class="token punctuation">)</span> <span class="token operator">OR</span> <span class="token punctuation">(</span>b <span class="token operator">&lt;&gt;</span> y<span class="token punctuation">)</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_less-than-or-equal">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_less-than-or-equal">
       <code class="literal">
        &lt;=
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207356992">
     </a>
     <a class="indexterm" name="idm46045207355888">
     </a>
     <p>
      Less than or equal:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa24322044"><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">SELECT</span> <span class="token number">0.1</span> <span class="token operator">&lt;=</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span></code></pre>
     </div>
     <p>
      For row comparisons,
      <code class="literal">
       (a, b) &lt;= (x, y)
      </code>
      is equivalent to:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa99196908"><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 punctuation">(</span>a <span class="token operator">&lt;</span> x<span class="token punctuation">)</span> <span class="token operator">OR</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>a <span class="token operator">=</span> x<span class="token punctuation">)</span> <span class="token operator">AND</span> <span class="token punctuation">(</span>b <span class="token operator">&lt;=</span> y<span class="token punctuation">)</span><span class="token punctuation">)</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_less-than">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_less-than">
       <code class="literal">
        &lt;
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207344016">
     </a>
     <a class="indexterm" name="idm46045207342928">
     </a>
     <p>
      Less than:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa49249301"><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">SELECT</span> <span class="token number">2</span> <span class="token operator">&lt;</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span></code></pre>
     </div>
     <p>
      For row comparisons,
      <code class="literal">
       (a, b) &lt; (x, y)
      </code>
      is equivalent to:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa46569991"><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 punctuation">(</span>a <span class="token operator">&lt;</span> x<span class="token punctuation">)</span> <span class="token operator">OR</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>a <span class="token operator">=</span> x<span class="token punctuation">)</span> <span class="token operator">AND</span> <span class="token punctuation">(</span>b <span class="token operator">&lt;</span> y<span class="token punctuation">)</span><span class="token punctuation">)</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_greater-than-or-equal">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_greater-than-or-equal">
       <code class="literal">
        &gt;=
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207330944">
     </a>
     <a class="indexterm" name="idm46045207329840">
     </a>
     <p>
      Greater than or equal:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa51601536"><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">SELECT</span> <span class="token number">2</span> <span class="token operator">&gt;=</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span></code></pre>
     </div>
     <p>
      For row comparisons,
      <code class="literal">
       (a, b) &gt;= (x, y)
      </code>
      is equivalent to:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa76384607"><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 punctuation">(</span>a <span class="token operator">&gt;</span> x<span class="token punctuation">)</span> <span class="token operator">OR</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>a <span class="token operator">=</span> x<span class="token punctuation">)</span> <span class="token operator">AND</span> <span class="token punctuation">(</span>b <span class="token operator">&gt;=</span> y<span class="token punctuation">)</span><span class="token punctuation">)</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_greater-than">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_greater-than">
       <code class="literal">
        &gt;
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207317984">
     </a>
     <a class="indexterm" name="idm46045207316896">
     </a>
     <p>
      Greater than:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90079518"><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">SELECT</span> <span class="token number">2</span> <span class="token operator">&gt;</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span></code></pre>
     </div>
     <p>
      For row comparisons,
      <code class="literal">
       (a, b) &gt; (x, y)
      </code>
      is equivalent to:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa91429220"><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 punctuation">(</span>a <span class="token operator">&gt;</span> x<span class="token punctuation">)</span> <span class="token operator">OR</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>a <span class="token operator">=</span> x<span class="token punctuation">)</span> <span class="token operator">AND</span> <span class="token punctuation">(</span>b <span class="token operator">&gt;</span> y<span class="token punctuation">)</span><span class="token punctuation">)</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_between">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_between">
       <code class="literal">
        <em class="replaceable">
         <code>
          expr
         </code>
        </em>
        BETWEEN
        <em class="replaceable">
         <code>
          min
         </code>
        </em>
        AND
        <em class="replaceable">
         <code>
          max
         </code>
        </em>
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207303968">
     </a>
     <p>
      If
      <em class="replaceable">
       <code>
        expr
       </code>
      </em>
      is greater than or equal
            to
      <em class="replaceable">
       <code>
        min
       </code>
      </em>
      and
      <em class="replaceable">
       <code>
        expr
       </code>
      </em>
      is less than or equal to
      <em class="replaceable">
       <code>
        max
       </code>
      </em>
      ,
      <a class="link" href="comparison-operators.html#operator_between">
       <code class="literal">
        BETWEEN
       </code>
      </a>
      returns
      <code class="literal">
       1
      </code>
      , otherwise it returns
      <code class="literal">
       0
      </code>
      . This is equivalent to the expression
      <code class="literal">
       (
       <em class="replaceable">
        <code>
         min
        </code>
       </em>
       &lt;=
       <em class="replaceable">
        <code>
         expr
        </code>
       </em>
       AND
       <em class="replaceable">
        <code>
         expr
        </code>
       </em>
       &lt;=
       <em class="replaceable">
        <code>
         max
        </code>
       </em>
       )
      </code>
      if all the
            arguments are of the same type. Otherwise type conversion
            takes place according to the rules described in
      <a class="xref" href="type-conversion.html" title="14.3 Type Conversion in Expression Evaluation">
       Section 14.3, “Type Conversion in Expression Evaluation”
      </a>
      , but applied to all the
            three arguments.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90764498"><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">SELECT</span> <span class="token number">2</span> <span class="token operator">BETWEEN</span> <span class="token number">1</span> <span class="token operator">AND</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">2</span> <span class="token operator">BETWEEN</span> <span class="token number">3</span> <span class="token operator">and</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token number">1</span> <span class="token operator">BETWEEN</span> <span class="token number">2</span> <span class="token operator">AND</span> <span class="token number">3</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token string">'b'</span> <span class="token operator">BETWEEN</span> <span class="token string">'a'</span> <span class="token operator">AND</span> <span class="token string">'c'</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token number">2</span> <span class="token operator">BETWEEN</span> <span class="token number">2</span> <span class="token operator">AND</span> <span class="token string">'3'</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token number">2</span> <span class="token operator">BETWEEN</span> <span class="token number">2</span> <span class="token operator">AND</span> <span class="token string">'x-3'</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span></code></pre>
     </div>
     <p>
      For best results when using
      <a class="link" href="comparison-operators.html#operator_between">
       <code class="literal">
        BETWEEN
       </code>
      </a>
      with date or time
            values, use
      <a class="link" href="cast-functions.html#function_cast">
       <code class="literal">
        CAST()
       </code>
      </a>
      to
            explicitly convert the values to the desired data type.
            Examples: If you compare a
      <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
       <code class="literal">
        DATETIME
       </code>
      </a>
      to two
      <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
       <code class="literal">
        DATE
       </code>
      </a>
      values, convert the
      <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
       <code class="literal">
        DATE
       </code>
      </a>
      values to
      <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
       <code class="literal">
        DATETIME
       </code>
      </a>
      values. If you use a
            string constant such as
      <code class="literal">
       '2001-1-1'
      </code>
      in a
            comparison to a
      <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
       <code class="literal">
        DATE
       </code>
      </a>
      , cast
            the string to a
      <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
       <code class="literal">
        DATE
       </code>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="operator_not-between">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_not-between">
       <code class="literal">
        <em class="replaceable">
         <code>
          expr
         </code>
        </em>
        NOT BETWEEN
        <em class="replaceable">
         <code>
          min
         </code>
        </em>
        AND
        <em class="replaceable">
         <code>
          max
         </code>
        </em>
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207271392">
     </a>
     <p>
      This is the same as
      <code class="literal">
       NOT
            (
       <em class="replaceable">
        <code>
         expr
        </code>
       </em>
       BETWEEN
       <em class="replaceable">
        <code>
         min
        </code>
       </em>
       AND
       <em class="replaceable">
        <code>
         max
        </code>
       </em>
       )
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="function_coalesce">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#function_coalesce">
       <code class="literal">
        COALESCE(
        <em class="replaceable">
         <code>
          value
         </code>
        </em>
        ,...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207261456">
     </a>
     <a class="indexterm" name="idm46045207260384">
     </a>
     <p>
      Returns the first non-
      <code class="literal">
       NULL
      </code>
      value in the
            list, or
      <code class="literal">
       NULL
      </code>
      if there are no
            non-
      <code class="literal">
       NULL
      </code>
      values.
     </p>
     <p>
      The return type of
      <a class="link" href="comparison-operators.html#function_coalesce">
       <code class="literal">
        COALESCE()
       </code>
      </a>
      is the aggregated type of the argument types.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa34886639"><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">SELECT</span> <span class="token function">COALESCE</span><span class="token punctuation">(</span><span class="token boolean">NULL</span><span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">COALESCE</span><span class="token punctuation">(</span><span class="token boolean">NULL</span><span class="token punctuation">,</span><span class="token boolean">NULL</span><span class="token punctuation">,</span><span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token boolean">NULL</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_exists">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_exists">
       <code class="literal">
        EXISTS(
        <em class="replaceable">
         <code>
          query
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207245200">
     </a>
     <p>
      Whether the result of a query contains any rows.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa59913101"><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 keyword">CREATE</span> <span class="token keyword">TABLE</span> t <span class="token punctuation">(</span>col <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token string">'aaa'</span><span class="token punctuation">,</span> <span class="token string">'bbb'</span><span class="token punctuation">,</span> <span class="token string">'ccc'</span><span class="token punctuation">,</span> <span class="token string">'eee'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">SELECT</span> <span class="token keyword">EXISTS</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> col <span class="token operator">LIKE</span> <span class="token string">'c%'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span>

<span class="token keyword">SELECT</span> <span class="token keyword">EXISTS</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> col <span class="token operator">LIKE</span> <span class="token string">'d%'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_not-exists">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_not-exists">
       <code class="literal">
        NOT
            EXISTS(
        <em class="replaceable">
         <code>
          query
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207235536">
     </a>
     <p>
      Whether the result of a query contains no rows:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3018353"><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 keyword">SELECT</span> <span class="token operator">NOT</span> <span class="token keyword">EXISTS</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> col <span class="token operator">LIKE</span> <span class="token string">'c%'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span>

<span class="token keyword">SELECT</span> <span class="token operator">NOT</span> <span class="token keyword">EXISTS</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> col <span class="token operator">LIKE</span> <span class="token string">'d%'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_greatest">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#function_greatest">
       <code class="literal">
        GREATEST(
        <em class="replaceable">
         <code>
          value1
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          value2
         </code>
        </em>
        ,...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207225264">
     </a>
     <p>
      With two or more arguments, returns the largest
            (maximum-valued) argument. The arguments are compared using
            the same rules as for
      <a class="link" href="comparison-operators.html#function_least">
       <code class="literal">
        LEAST()
       </code>
      </a>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa37708795"><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">SELECT</span> <span class="token function">GREATEST</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">2</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">GREATEST</span><span class="token punctuation">(</span><span class="token number">34.0</span><span class="token punctuation">,</span><span class="token number">3.0</span><span class="token punctuation">,</span><span class="token number">5.0</span><span class="token punctuation">,</span><span class="token number">767.0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">767.0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">GREATEST</span><span class="token punctuation">(</span><span class="token string">'B'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">,</span><span class="token string">'C'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token string">'C'</span></code></pre>
     </div>
     <p>
      <a class="link" href="comparison-operators.html#function_greatest">
       <code class="literal">
        GREATEST()
       </code>
      </a>
      returns
      <code class="literal">
       NULL
      </code>
      if any argument is
      <code class="literal">
       NULL
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="operator_in">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_in">
       <code class="literal">
        <em class="replaceable">
         <code>
          expr
         </code>
        </em>
        IN (
        <em class="replaceable">
         <code>
          value
         </code>
        </em>
        ,...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207208912">
     </a>
     <p>
      Returns
      <code class="literal">
       1
      </code>
      (true) if
      <em class="replaceable">
       <code>
        expr
       </code>
      </em>
      is equal to any of the
            values in the
      <code class="literal">
       IN()
      </code>
      list, else returns
      <code class="literal">
       0
      </code>
      (false).
     </p>
     <p>
      Type conversion takes place according to the rules described
            in
      <a class="xref" href="type-conversion.html" title="14.3 Type Conversion in Expression Evaluation">
       Section 14.3, “Type Conversion in Expression Evaluation”
      </a>
      , applied to all the
            arguments. If no type conversion is needed for the values in
            the
      <code class="literal">
       IN()
      </code>
      list, they are all
            non-
      <code class="literal">
       JSON
      </code>
      constants of the same type, and
      <em class="replaceable">
       <code>
        expr
       </code>
      </em>
      can be compared to each of
            them as a value of the same type (possibly after type
            conversion), an optimization takes place. The values the
            list are sorted and the search for
      <em class="replaceable">
       <code>
        expr
       </code>
      </em>
      is done using a binary
            search, which makes the
      <code class="literal">
       IN()
      </code>
      operation
            very quick.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa56312847"><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">SELECT</span> <span class="token number">2</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token string">'wefwf'</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token string">'wee'</span><span class="token punctuation">,</span><span class="token string">'wefwf'</span><span class="token punctuation">,</span><span class="token string">'weg'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span></code></pre>
     </div>
     <p>
      <code class="literal">
       IN()
      </code>
      can be used to compare row
            constructors:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa76408549"><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">SELECT</span> <span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span></code></pre>
     </div>
     <p>
      You should never mix quoted and unquoted values in an
      <code class="literal">
       IN()
      </code>
      list because the comparison rules
            for quoted values (such as strings) and unquoted values
            (such as numbers) differ. Mixing types may therefore lead to
            inconsistent results. For example, do not write an
      <code class="literal">
       IN()
      </code>
      expression like this:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa63478292"><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 keyword">SELECT</span> val1 <span class="token keyword">FROM</span> tbl1 <span class="token keyword">WHERE</span> val1 <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token string">'a'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      Instead, write it like this:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa51052415"><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 keyword">SELECT</span> val1 <span class="token keyword">FROM</span> tbl1 <span class="token keyword">WHERE</span> val1 <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token string">'1'</span><span class="token punctuation">,</span><span class="token string">'2'</span><span class="token punctuation">,</span><span class="token string">'a'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      Implicit type conversion may produce nonintuitive results:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa94526444"><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">SELECT</span> <span class="token string">'a'</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token string">'b'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">1</span></code></pre>
     </div>
     <p>
      In both cases, the comparison values are converted to
            floating-point values, yielding 0.0 in each case, and a
            comparison result of 1 (true).
     </p>
     <p>
      The number of values in the
      <code class="literal">
       IN()
      </code>
      list is
            only limited by the
      <a class="link" href="server-system-variables.html#sysvar_max_allowed_packet">
       <code class="literal">
        max_allowed_packet
       </code>
      </a>
      value.
     </p>
     <p>
      To comply with the SQL standard,
      <code class="literal">
       IN()
      </code>
      returns
      <code class="literal">
       NULL
      </code>
      not only if the expression
            on the left hand side is
      <code class="literal">
       NULL
      </code>
      , but also
            if no match is found in the list and one of the expressions
            in the list is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <p>
      <code class="literal">
       IN()
      </code>
      syntax can also be used to write
            certain types of subqueries. See
      <a class="xref" href="any-in-some-subqueries.html" title="15.2.15.3 Subqueries with ANY, IN, or SOME">
       Section 15.2.15.3, “Subqueries with ANY, IN, or SOME”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="operator_not-in">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_not-in">
       <code class="literal">
        <em class="replaceable">
         <code>
          expr
         </code>
        </em>
        NOT IN (
        <em class="replaceable">
         <code>
          value
         </code>
        </em>
        ,...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207171696">
     </a>
     <p>
      This is the same as
      <code class="literal">
       NOT
            (
       <em class="replaceable">
        <code>
         expr
        </code>
       </em>
       IN
            (
       <em class="replaceable">
        <code>
         value
        </code>
       </em>
       ,...))
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="function_interval">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#function_interval">
       <code class="literal">
        INTERVAL(
        <em class="replaceable">
         <code>
          N
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          N1
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          N2
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          N3
         </code>
        </em>
        ,...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207160848">
     </a>
     <p>
      Returns
      <code class="literal">
       0
      </code>
      if
      <em class="replaceable">
       <code>
        N
       </code>
      </em>
      ≤
      <em class="replaceable">
       <code>
        N1
       </code>
      </em>
      ,
      <code class="literal">
       1
      </code>
      if
      <em class="replaceable">
       <code>
        N
       </code>
      </em>
      ≤
      <em class="replaceable">
       <code>
        N2
       </code>
      </em>
      and so on, or
      <code class="literal">
       -1
      </code>
      if
      <em class="replaceable">
       <code>
        N
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      . All arguments are treated as
            integers. It is required that
      <em class="replaceable">
       <code>
        N1
       </code>
      </em>
      ≤
      <em class="replaceable">
       <code>
        N2
       </code>
      </em>
      ≤
      <em class="replaceable">
       <code>
        N3
       </code>
      </em>
      ≤
      <code class="literal">
       ...
      </code>
      ≤
      <em class="replaceable">
       <code>
        Nn
       </code>
      </em>
      for this function to work
            correctly. This is because a binary search is used (very
            fast).
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90942116"><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">SELECT</span> <span class="token keyword">INTERVAL</span><span class="token punctuation">(</span><span class="token number">23</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">15</span><span class="token punctuation">,</span> <span class="token number">17</span><span class="token punctuation">,</span> <span class="token number">30</span><span class="token punctuation">,</span> <span class="token number">44</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">3</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token keyword">INTERVAL</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">,</span> <span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">2</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token keyword">INTERVAL</span><span class="token punctuation">(</span><span class="token number">22</span><span class="token punctuation">,</span> <span class="token number">23</span><span class="token punctuation">,</span> <span class="token number">30</span><span class="token punctuation">,</span> <span class="token number">44</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_is">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_is">
       <code class="literal">
        IS
        <em class="replaceable">
         <code>
          boolean_value
         </code>
        </em>
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207141904">
     </a>
     <a class="indexterm" name="idm46045207140416">
     </a>
     <a class="indexterm" name="idm46045207138928">
     </a>
     <a class="indexterm" name="idm46045207137440">
     </a>
     <p>
      Tests a value against a boolean value, where
      <em class="replaceable">
       <code>
        boolean_value
       </code>
      </em>
      can be
      <code class="literal">
       TRUE
      </code>
      ,
      <code class="literal">
       FALSE
      </code>
      , or
      <code class="literal">
       UNKNOWN
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa58580644"><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">SELECT</span> <span class="token number">1</span> <span class="token operator">IS</span> <span class="token boolean">TRUE</span><span class="token punctuation">,</span> <span class="token number">0</span> <span class="token operator">IS</span> <span class="token boolean">FALSE</span><span class="token punctuation">,</span> <span class="token boolean">NULL</span> <span class="token operator">IS</span> <span class="token keyword">UNKNOWN</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">1</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_is-not">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_is-not">
       <code class="literal">
        IS NOT
        <em class="replaceable">
         <code>
          boolean_value
         </code>
        </em>
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207124816">
     </a>
     <a class="indexterm" name="idm46045207123328">
     </a>
     <a class="indexterm" name="idm46045207121840">
     </a>
     <a class="indexterm" name="idm46045207120352">
     </a>
     <p>
      Tests a value against a boolean value, where
      <em class="replaceable">
       <code>
        boolean_value
       </code>
      </em>
      can be
      <code class="literal">
       TRUE
      </code>
      ,
      <code class="literal">
       FALSE
      </code>
      , or
      <code class="literal">
       UNKNOWN
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa63641583"><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">SELECT</span> <span class="token number">1</span> <span class="token operator">IS</span> <span class="token operator">NOT</span> <span class="token keyword">UNKNOWN</span><span class="token punctuation">,</span> <span class="token number">0</span> <span class="token operator">IS</span> <span class="token operator">NOT</span> <span class="token keyword">UNKNOWN</span><span class="token punctuation">,</span> <span class="token boolean">NULL</span> <span class="token operator">IS</span> <span class="token operator">NOT</span> <span class="token keyword">UNKNOWN</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">0</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_is-null">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_is-null">
       <code class="literal">
        IS NULL
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207108000">
     </a>
     <a class="indexterm" name="idm46045207106512">
     </a>
     <p>
      Tests whether a value is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa53132043"><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">SELECT</span> <span class="token number">1</span> <span class="token operator">IS</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span> <span class="token number">0</span> <span class="token operator">IS</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span> <span class="token boolean">NULL</span> <span class="token operator">IS</span> <span class="token boolean">NULL</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">1</span></code></pre>
     </div>
     <p>
      To work well with ODBC programs, MySQL supports the
            following extra features when using
      <a class="link" href="comparison-operators.html#operator_is-null">
       <code class="literal">
        IS
            NULL
       </code>
      </a>
      :
     </p>
     <a class="indexterm" name="idm46045207098752">
     </a>
     <a class="indexterm" name="idm46045207097680">
     </a>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         If
         <a class="link" href="server-system-variables.html#sysvar_sql_auto_is_null">
          <code class="literal">
           sql_auto_is_null
          </code>
         </a>
         variable is set to 1, then after a statement that
                successfully inserts an automatically generated
         <code class="literal">
          AUTO_INCREMENT
         </code>
         value, you can find
                that value by issuing a statement of the following form:
        </p>
        <div class="copytoclipboard-wrapper">
         <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa39169983"><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 keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em> <span class="token keyword">WHERE</span> <em class="replaceable">auto_col</em> <span class="token operator">IS</span> <span class="token boolean">NULL</span></code></pre>
        </div>
        <p>
         If the statement returns a row, the value returned is
                the same as if you invoked the
         <a class="link" href="information-functions.html#function_last-insert-id">
          <code class="literal">
           LAST_INSERT_ID()
          </code>
         </a>
         function. For details, including the return value after
                a multiple-row insert, see
         <a class="xref" href="information-functions.html" title="14.15 Information Functions">
          Section 14.15, “Information Functions”
         </a>
         . If no
         <code class="literal">
          AUTO_INCREMENT
         </code>
         value was successfully
                inserted, the
         <a class="link" href="select.html" title="15.2.13 SELECT Statement">
          <code class="literal">
           SELECT
          </code>
         </a>
         statement returns no row.
        </p>
        <p>
         The behavior of retrieving an
         <code class="literal">
          AUTO_INCREMENT
         </code>
         value by using an
         <a class="link" href="comparison-operators.html#operator_is-null">
          <code class="literal">
           IS NULL
          </code>
         </a>
         comparison can be
                disabled by setting
         <a class="link" href="server-system-variables.html#sysvar_sql_auto_is_null">
          <code class="literal">
           sql_auto_is_null = 0
          </code>
         </a>
         .
                See
         <a class="xref" href="server-system-variables.html" title="7.1.8 Server System Variables">
          Section 7.1.8, “Server System Variables”
         </a>
         .
        </p>
        <p>
         The default value of
         <a class="link" href="server-system-variables.html#sysvar_sql_auto_is_null">
          <code class="literal">
           sql_auto_is_null
          </code>
         </a>
         is 0.
        </p>
       </li>
       <li class="listitem">
        <p>
         For
         <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
          <code class="literal">
           DATE
          </code>
         </a>
         and
         <a class="link" href="datetime.html" title="13.2.2 The DATE, DATETIME, and TIMESTAMP Types">
          <code class="literal">
           DATETIME
          </code>
         </a>
         columns that are
                declared as
         <code class="literal">
          NOT NULL
         </code>
         , you can find
                the special date
         <code class="literal">
          '0000-00-00'
         </code>
         by
                using a statement like this:
        </p>
        <div class="copytoclipboard-wrapper">
         <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa82828835"><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 keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em> <span class="token keyword">WHERE</span> <em class="replaceable">date_column</em> <span class="token operator">IS</span> <span class="token boolean">NULL</span></code></pre>
        </div>
        <p>
         This is needed to get some ODBC applications to work
                because ODBC does not support a
         <code class="literal">
          '0000-00-00'
         </code>
         date value.
        </p>
        <p>
         See
         <a class="ulink" href="/doc/connector-odbc/en/connector-odbc-usagenotes-functionality-last-insert-id.html" target="_top">
          Obtaining Auto-Increment Values
         </a>
         ,
                and the description for the
         <code class="literal">
          FLAG_AUTO_IS_NULL
         </code>
         option at
         <a class="ulink" href="/doc/connector-odbc/en/connector-odbc-configuration-connection-parameters.html" target="_top">
          Connector/ODBC Connection Parameters
         </a>
         .
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <a name="operator_is-not-null">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#operator_is-null">
       <code class="literal">
        IS NOT NULL
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207065168">
     </a>
     <a class="indexterm" name="idm46045207063680">
     </a>
     <p>
      Tests whether a value is not
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3409621"><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">SELECT</span> <span class="token number">1</span> <span class="token operator">IS</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span> <span class="token number">0</span> <span class="token operator">IS</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span> <span class="token boolean">NULL</span> <span class="token operator">IS</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">0</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_isnull">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#function_isnull">
       <code class="literal">
        ISNULL(
        <em class="replaceable">
         <code>
          expr
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207052800">
     </a>
     <p>
      If
      <em class="replaceable">
       <code>
        expr
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      ,
      <a class="link" href="comparison-operators.html#function_isnull">
       <code class="literal">
        ISNULL()
       </code>
      </a>
      returns
      <code class="literal">
       1
      </code>
      , otherwise it returns
      <code class="literal">
       0
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa48433968"><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">SELECT</span> <span class="token function">ISNULL</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ISNULL</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token operator">/</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span></code></pre>
     </div>
     <p>
      <a class="link" href="comparison-operators.html#function_isnull">
       <code class="literal">
        ISNULL()
       </code>
      </a>
      can be used instead
            of
      <a class="link" href="comparison-operators.html#operator_equal">
       <code class="literal">
        =
       </code>
      </a>
      to test
            whether a value is
      <code class="literal">
       NULL
      </code>
      . (Comparing a
            value to
      <code class="literal">
       NULL
      </code>
      using
      <a class="link" href="comparison-operators.html#operator_equal">
       <code class="literal">
        =
       </code>
      </a>
      always
            yields
      <code class="literal">
       NULL
      </code>
      .)
     </p>
     <p>
      The
      <a class="link" href="comparison-operators.html#function_isnull">
       <code class="literal">
        ISNULL()
       </code>
      </a>
      function shares
            some special behaviors with the
      <a class="link" href="comparison-operators.html#operator_is-null">
       <code class="literal">
        IS NULL
       </code>
      </a>
      comparison operator. See the description of
      <a class="link" href="comparison-operators.html#operator_is-null">
       <code class="literal">
        IS NULL
       </code>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="function_least">
     </a>
     <p>
      <a class="link" href="comparison-operators.html#function_least">
       <code class="literal">
        LEAST(
        <em class="replaceable">
         <code>
          value1
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          value2
         </code>
        </em>
        ,...)
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045207027264">
     </a>
     <p>
      With two or more arguments, returns the smallest
            (minimum-valued) argument. The arguments are compared using
            the following rules:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         If any argument is
         <code class="literal">
          NULL
         </code>
         , the result
                is
         <code class="literal">
          NULL
         </code>
         . No comparison is needed.
        </p>
       </li>
       <li class="listitem">
        <p>
         If all arguments are integer-valued, they are compared
                as integers.
        </p>
       </li>
       <li class="listitem">
        <p>
         If at least one argument is double precision, they are
                compared as double-precision values. Otherwise, if at
                least one argument is a
         <a class="link" href="fixed-point-types.html" title="13.1.3 Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC">
          <code class="literal">
           DECIMAL
          </code>
         </a>
         value, they are
                compared as
         <a class="link" href="fixed-point-types.html" title="13.1.3 Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC">
          <code class="literal">
           DECIMAL
          </code>
         </a>
         values.
        </p>
       </li>
       <li class="listitem">
        <p>
         If the arguments comprise a mix of numbers and strings,
                they are compared as strings.
        </p>
       </li>
       <li class="listitem">
        <p>
         If any argument is a nonbinary (character) string, the
                arguments are compared as nonbinary strings.
        </p>
       </li>
       <li class="listitem">
        <p>
         In all other cases, the arguments are compared as binary
                strings.
        </p>
       </li>
      </ul>
     </div>
     <p>
      The return type of
      <a class="link" href="comparison-operators.html#function_least">
       <code class="literal">
        LEAST()
       </code>
      </a>
      is
            the aggregated type of the comparison argument types.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa79646191"><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">SELECT</span> <span class="token function">LEAST</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LEAST</span><span class="token punctuation">(</span><span class="token number">34.0</span><span class="token punctuation">,</span><span class="token number">3.0</span><span class="token punctuation">,</span><span class="token number">5.0</span><span class="token punctuation">,</span><span class="token number">767.0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">3.0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LEAST</span><span class="token punctuation">(</span><span class="token string">'B'</span><span class="token punctuation">,</span><span class="token string">'A'</span><span class="token punctuation">,</span><span class="token string">'C'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token string">'A'</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
