数据库结构很简单,有: id ,ip ,date 三个字段。我想查询 在距离现在10 分钟内, 同一个ip的入库记录数,关键问题是 那个 10 分钟我不会控制,不太了解 mysql中的时间函数是怎么用的,有 date_sub 以及 date_add sysdate 但是 我写的语句却不正确,请指点!
我的sql语句是:select count(*) from ask_account_tell where account_ip = '119.253.59.50' and account_date > date_sub(sysdate(),interval 10 minute) and account_date < sysdate()
我的sql语句是:select count(*) from ask_account_tell where account_ip = '119.253.59.50' and account_date > date_sub(sysdate(),interval 10 minute) and account_date < sysdate()
解决方案 »
- mysql_cluster测试 请问如何进行1000亿的事务请求
- mysql语句报错了,求解决
- Column count doesn't match value count at row 1
- my sql连接jsp界面
- 如何将MYSQL 数据库 转成 SQL SERVER数据库??
- 急!下载mysql-3.23.58-9.i386.rpm安装后无法运行service mysqld start,mysql服务无法运行
- 【急】PostgreSQL网络地址数据类型INET在MySQL可用什么数据类型替换?
- 数据库MySQL提问如何把表中元素的default null修改成not null?或者not null修改成default null
- MySql 远程连接失败,求解答
- 新人请教:UPDATE 怎样更新长文本?
- NDB的join的连接操作需要巨大的网络开销,这个何解?
- 很简单的删除语句,怎么会错误?
where account_ip = '119.253.59.50'
and account_date > now()+interval 10 minute and account_date<now()
不怎么好使啊 我直接先运行
select count(*) from ask_account_tell
where account_date > now() - interval 24 hour结果集也是 0 按说是应该有记录的,不应该是 0 的
谢谢你哈 我已经解决了,sql语句如下,我把 account_date 改成日期格式了,不是时间戳形式了。
select count(*) as nums from ask_account_tell where account_ip = '."'$ip'".' and account_date > DATE_SUB(now(),INTERVAL 10 MINUTE) and account_date < now()'