如何使用MySQL选择小于当前日期的日期?
让我们首先创建一个表-
mysql> create table DemoTable1877 ( DueDate datetime );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1877 values('2019-12-10');
mysql> insert into DemoTable1877 values('2019-12-05');
mysql> insert into DemoTable1877 values('2019-12-07');
mysql> insert into DemoTable1877 values('2019-12-09');使用select语句显示表中的所有记录-
mysql> select * from DemoTable1877;
这将产生以下输出-
+---------------------+ | DueDate | +---------------------+ | 2019-12-10 00:00:00 | | 2019-12-05 00:00:00 | | 2019-12-07 00:00:00 | | 2019-12-09 00:00:00 | +---------------------+ 4 rows in set (0.00 sec)
当前日期如下-
mysql> select curdate(); +------------+ | curdate() | +------------+ | 2019-12-08 | +------------+ 1 row in set (0.00 sec)
这是选择小于当前日期的日期的查询-
mysql> select * from DemoTable1877 where DueDate < now();
这将产生以下输出-
+---------------------+ | DueDate | +---------------------+ | 2019-12-05 00:00:00 | | 2019-12-07 00:00:00 | +---------------------+ 2 rows in set (0.00 sec)
热门推荐
10 小学毕业父母简短祝福语
11 幼儿生日祝福语模板简短
12 新娘妈妈的祝福语简短
13 邻居聚会祝福语大全简短
14 十条祝福语简短
15 给同学祝福语的简短
16 过年祝福语简短祝妈妈
17 祝女儿简短祝福语大全
18 恩师诗词祝福语简短大全