Home  >  Article  >  Database  >  How do comparison operators in MySQL work with date values?

How do comparison operators in MySQL work with date values?

WBOY
WBOYforward
2023-09-05 15:49:10493browse

MySQL 中的比较运算符如何处理日期值?

Comparison operators between dates will work in a logical manner. In the following example, when comparing two dates, MySQL simply compares two numbers or strings -

mysql> select 20171027 < 20150825;
+---------------------------+
| 20171027 < 20150825       |
+---------------------------+
|                      0    |
+---------------------------+
1 row in set (0.00 sec)

The output 0 indicates that the result of the above query is FALSE.

mysql> select 20171027 > 20150825;
+--------------------------+
| 20171027 > 20150825      |
+--------------------------+
|                      1   |
+--------------------------+
1 row in set (0.00 sec)

Output "1" indicates that the result of the above query is TRUE.

The above is the detailed content of How do comparison operators in MySQL work with date values?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete