查询'2010-08-31 18:06:43' 到 '2010-08-31 18:07:51'的结果集
select * from test where time between '2010-08-31 18:06:43' and '2010-08-31 18:07:51';
+----+------+------+---------------------+
| id | code | name | time |
+----+------+------+---------------------+
| 1 | 1 | aaa | 2010-08-31 18:06:51 |
| 2 | 2 | aaa | 2010-08-31 18:06:52 |
| 3 | 1 | b | 2010-08-31 18:06:54 |
| 4 | 3 | b | 2010-08-31 18:06:48 |
| 5 | 2 | b | 2010-08-31 18:06:47 |
| 6 | 1 | c | 2010-08-31 18:06:46 |
| 7 | 4 | c | 2010-08-31 18:06:43 |
+----+------+------+---------------------+
或者
mysql> select * from test where time>='2010-08-31 18:06:43' and time <='2010-0
31 18:07:51';
+----+------+------+---------------------+
| id | code | name | time |
+----+------+------+---------------------+
| 1 | 1 | aaa | 2010-08-31 18:06:51 |
| 2 | 2 | aaa | 2010-08-31 18:06:52 |
| 3 | 1 | b | 2010-08-31 18:06:54 |
| 4 | 3 | b | 2010-08-31 18:06:48 |
| 5 | 2 | b | 2010-08-31 18:06:47 |
| 6 | 1 | c | 2010-08-31 18:06:46 |
| 7 | 4 | c | 2010-08-31 18:06:43 |
+----+------+------+---------------------+
select * from test where time between '2010-08-31 18:06:43' and '2010-08-31 18:07:51';
+----+------+------+---------------------+
| id | code | name | time |
+----+------+------+---------------------+
| 1 | 1 | aaa | 2010-08-31 18:06:51 |
| 2 | 2 | aaa | 2010-08-31 18:06:52 |
| 3 | 1 | b | 2010-08-31 18:06:54 |
| 4 | 3 | b | 2010-08-31 18:06:48 |
| 5 | 2 | b | 2010-08-31 18:06:47 |
| 6 | 1 | c | 2010-08-31 18:06:46 |
| 7 | 4 | c | 2010-08-31 18:06:43 |
+----+------+------+---------------------+
或者
mysql> select * from test where time>='2010-08-31 18:06:43' and time <='2010-0
31 18:07:51';
+----+------+------+---------------------+
| id | code | name | time |
+----+------+------+---------------------+
| 1 | 1 | aaa | 2010-08-31 18:06:51 |
| 2 | 2 | aaa | 2010-08-31 18:06:52 |
| 3 | 1 | b | 2010-08-31 18:06:54 |
| 4 | 3 | b | 2010-08-31 18:06:48 |
| 5 | 2 | b | 2010-08-31 18:06:47 |
| 6 | 1 | c | 2010-08-31 18:06:46 |
| 7 | 4 | c | 2010-08-31 18:06:43 |
+----+------+------+---------------------+