求 mysql 一条查询语句
时间:2011-11-11
来源:互联网
数据库结构很简单,有: 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()
我想查询 在距离现在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()
作者: shenmdouyourenjiaole 发布时间: 2011-11-11
SQL code
select count(*) from ask_account_tell where account_ip = '119.253.59.50' and account_date > now()+interval 10 minute and account_date<now()
作者: ACMAIN_CHM 发布时间: 2011-11-11
引用 1 楼 acmain_chm 的回复:
SQL code
select count(*) from ask_account_tell
where account_ip = '119.253.59.50'
and account_date > now()+interval 10 minute and account_date<now()
SQL code
select count(*) from ask_account_tell
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 的
作者: shenmdouyourenjiaole 发布时间: 2011-11-11
贴一条你认为符合条件的记录出来以供分析。 另外贴一下你的 desc ask_account_tell
作者: ACMAIN_CHM 发布时间: 2011-11-11
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28