MySQL通过时间差异删除() [英] Mysql delete by difference in time()
本文介绍了MySQL通过时间差异删除()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除时差为5分钟的每一行.我正在使用time()作为整数.
I want to delete every row where the time difference is 5 minutes. I'm using time() as an int.
mysql_query("DELETE FROM users WHERE time()-time > 300");
查询是问题所在...
the query is the problem...
推荐答案
time()
是一个PHP函数-在SQL中绝对没有意义.
time()
is a PHP function -- and has absolutely no meaning in SQL.
您应该:
- 使用MySQL的 datetime函数之一
- 要获得UNIX时间戳,我想
unix_timestamp(now())
可以解决问题.
- use one of MySQL's datetime functions
- To get an UNIX Timestamp, I suppose
unix_timestamp(now())
might do the trick.
例如,使用第二个想法,我想您可以做这样的事情:
For example, using the second idea, I suppose you could do something like this :mysql_query("DELETE FROM users WHERE " . time() . "-time > 300");
这篇关于MySQL通过时间差异删除()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- To get an UNIX Timestamp, I suppose
- 要获得UNIX时间戳,我想
查看全文