本文介绍了如何使用PHP从MySQL中选择最后3分钟的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的SQL表:

+----------------+----------------+-----------+------------------------+ 
|   User_Name    |    Password    |    IP     |        Login_Time      |
+----------------+----------------+-----------+------------------------+
|  rthrthrhrt    |   fjdjetje5e   | 127.0.0.1 |   2011-09-24 18:02:06  |
|  Empty         |   Empty        | 127.0.0.1 |   2011-09-24 18:10:01  |
|  Empty         |   Empty        | 127.0.0.1 |   2011-09-24 18:04:00  |
|  rsyrt         |   rwytw4364    | 127.0.0.1 |   2011-09-24 18:08:59  |
|  eryrjrj5      |   Empty        | 127.0.0.1 |   2011-09-24 18:03:56  |
|  reutreuetry   |   reuretyre    | 127.0.0.1 |   2011-09-24 18:06:53  |
|  Empty         |   rthrtrt      | 127.0.0.1 |   2011-09-24 18:05:51  |
|  djdjgdjh      |   66735        | 127.0.0.1 |   2011-09-24 18:09:49  |
|  fgjdgjdhg     |   Empty        | 127.0.0.1 |   2011-09-24 18:07:46  |
|  Empty         |   Empty        | 127.0.0.1 |   2011-09-24 18:11:43  |
+----------------+----------------+-----------+------------------------+

我正在用PHP和MySQL开发一个蛮力的插件.我想选择最后3分钟的记录.

I am developing a brute force addon with PHP and MySQL. I would like to select last 3 minutes' records.

例如(我想做什么?):时间现在是:2011-09-26 9:45:00.我想选择2011-09-26 9:45:00和2011-09-26 9:42:00之间的所有记录.

for example (what i'd like to do?): time is now: 2011-09-26 9:45:00. i would like to select all records between 2011-09-26 9:45:00 and 2011-09-26 9:42:00.

推荐答案

使用此sql查询:

select * from myTable where Login_time > date_sub(now(), interval 3 minute) ;

这篇关于如何使用PHP从MySQL中选择最后3分钟的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 05:07