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

How do comparison operators in MySQL work with date values?

WBOY
Release: 2023-09-06 09:28:47
forward
524 people have browsed it

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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template