让我们首先创建一个表-
mysql> create table DemoTable1871 ( ArrivalDate datetime );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1871 values('2019-12-19 7:45:00'); mysql> insert into DemoTable1871 values('2018-11-10 12:00:00'); mysql> insert into DemoTable1871 values('2019-01-31');
使用select语句显示表中的所有记录-
mysql> select * from DemoTable1871;
这将产生以下输出-
+---------------------+ | ArrivalDate | +---------------------+ | 2019-12-19 07:45:00 | | 2018-11-10 12:00:00 | | 2019-01-31 00:00:00 | +---------------------+ 3 rows in set (0.00 sec)
这是添加天数的查询-
mysql> update DemoTable1871 set ArrivalDate=date_add(ArrivalDate, interval 6 day); Rows matched: 3 Changed: 3 Warnings: 0
让我们再次检查表记录-
mysql> select * from DemoTable1871;
这将产生以下输出-
+---------------------+ | ArrivalDate | +---------------------+ | 2019-12-25 07:45:00 | | 2018-11-16 12:00:00 | | 2019-02-06 00:00:00 | +---------------------+ 3 rows in set (0.00 sec)