How does comparison operator work with date values in MySQL?

MySQLMySQLi Database

<p>Comparison operator between dates will work in a logical way. In the following example, while comparing two dates, MySQL is simply comparing two numbers or string &minus;</p><pre class="prettyprint notranslate">mysql&gt; select 20171027 &lt; 20150825; +---------------------------+ | 20171027 &lt; 20150825 &nbsp; &nbsp; &nbsp; | +---------------------------+ | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp;| +---------------------------+ 1 row in set (0.00 sec)</pre><p>The 0 output shows that the result of the above query is FALSE.</p><pre class="prettyprint notranslate">mysql&gt; select 20171027 &gt; 20150825; +--------------------------+ | 20171027 &gt; 20150825 &nbsp; &nbsp; &nbsp;| +--------------------------+ | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp; | +--------------------------+ 1 row in set (0.00 sec)</pre><p>The output &lsquo;1&rsquo; shows that the result of the above query is TRUE.</p>
raja
Updated on 28-Jan-2020 10:41:23

Advertisements