你能做一个mysqli选择查询来获取所有带有时间戳的行,从x到x [重复]

This question already has an answer here:

I have a database setup where there are three columns:

  • name
  • email
  • timestamp (standard Unix timestamp)

What I would like to do is to select all rows between two timestamps.

Example:

+-------+---------+------+
| name  | email   | time |
+-------+---------+------+
| dave  | mymail  | 1234 |
| john  | hismail | 1235 |
| jim   | mail    | 1236 |
| liam  | mail1   | 1237 |
| colin | mail2   | 1238 |
+-------+---------+------+

I would like to select all rows between 1235 to 1237 (all rows in between) - how do I do this?

</div>
SELECT `name`, `email`, `time` FROM `table` WHERE `time` >= 1235 AND `time` <= 1237

BETWEEN operator will help you

SELECT `name`, `email`, `time` FROM `table` WHERE `time` BETWEEN 1235 AND 1237;