让我们首先创建一个表-mysql> create table DemoTable1495
-> (
-> ShippingDate bigint
-> );
使用插入命令在表中插入一些记录-mysql> insert into DemoTable1495 values(1570127400);
mysql> insert into DemoTable1495 values(1570213800);
mysql> insert into DemoTable1495 values(1570645800);
mysql> insert into DemoTable1495 values(1570300200);
使用select语句显示表中的所有记录-mysql> select * from DemoTable1495;
这将产生以下输出-+--------------+
| ShippingDate |
+--------------+
| 1570127400 |
| 1570213800 |
| 1570645800 |
| 1570300200 |
+--------------+
4 rows in set (0.00 sec)
当前日期如下-mysql> select curdate();
+------------+
| curdate() |
+------------+
| 2019-10-06 |
+------------+
1 row in set (0.00 sec)
这是从MySQL获取两天数据的查询-mysql> select * from DemoTable1495
-> where ShippingDate >=unix_timestamp(curdate() - interval 1 day)
-> and
-> ShippingDate
这将产生以下输出-+--------------+
| ShippingDate |
+--------------+
| 1570213800 |
| 1570300200 |
+--------------+
2 rows in set (0.00 sec)