本周内:
select * from wap_content where week(created_at) = week(now)

查询一天:
select * from table where to_days(column_time) = to_days(now());select * from table where date(column_time) = curdate();

查询7天:
select * from table  where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(column_time);

查询一个月:
select * from table  where DATE_SUB(CURDATE(), INTERVAL INTERVAL 1 MONTH) <= date(column_time);

转自:http://blog.163.com/very_apple/blog/static/2775923620133210232571/

MySql 查询一周内最近7天记录的更多相关文章

  1. MYSQL查询一周内的数据(最近7天的)、最近一个月、最近三个月数据

    如果你要严格要求是某一年的,那可以这样 查询一天: select * from table where to_days(column_time) = to_days(now()); select * ...

  2. MYSQL查询一周内的数据(最近7天的)

    select * from wap_content where week(created_at) = week(now) 如果你要严格要求是某一年的,那可以这样 查询一天: select * from ...

  3. MySql 查询一周内记录

    本周内:select * from wap_content where week(created_at) = week(now) 查询一天:select * from table where to_d ...

  4. mysql查询各种类型的前N条记录

    mysql查询各种类型的前N条记录,将3改为N(需查询条数)即可  (select * from event_info where event_type = 1  limit 3)union all( ...

  5. MySQL 查询某个数据库中所有包含数据记录的表名

    MySQL 查询某个数据库中所有包含数据记录的表名 有时根据实际应用需要,需要对数据进行备份. 如果一个数据库中有很多数据表,但是只想备份包含数据记录的那些表数据(空表不做数据备份). 如果通过如下S ...

  6. Mysql 查询一天中每半小时记录的数量

    SELECT HOUR(e.time)as Hour,FLOOR(MINUTE(e.time)/30) as M, COUNT(*) as Count FROM error_log e WHERE e ...

  7. MySql查询日周月

    常用计算日期的函数 日 date(日期) = CURDATE() 自然周 YEARWEEK(date_format(日期,'%Y-%m-%d') , 1) = YEARWEEK(now() , 1) ...

  8. mysql 查询,天,周,月等写法

    1.查询当天的数据 select * from 表名 where TO_DAYS(时间字段)=TO_DAYS(NOW()); 2.查询当周的数据 select * from 表名 where YEAR ...

  9. SQL查询一周内过生日的用户

    SELECT birthday, )) + '-' + )) + '-' + )) AS datetime) AS Nbirthday FROM CRM_Customer WHERE birthday ...

随机推荐

  1. SrcollView分页加载数据(第二种方法 自定义listView)

    package com.baidu.ms; import android.content.Context;import android.util.AttributeSet;import android ...

  2. app store 上架流程

    前言:作为一名IOS开发者,把开发出来的App上传到App Store是必须的.下面就来详细介绍下具体流程. 1.打开苹果开发者中心:https://developer.apple.com 打开后点击 ...

  3. iphone获取当前运行进程列表

    通过调用 sys/sysctl.h 读取系统内核获取进程列表 . 代码悦德财富:https://yuedecaifu.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 ...

  4. WEB-INF& 绝对路径vs相对路径

    在struts2里面用XXXInput方法和springmvc里面用GET模式进入添加或者登陆输入页面,有时候会在方法里面做一下准备,比如动态读入部门信息放在select中,或者在model中加入一个 ...

  5. Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

    Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK fla ...

  6. C/C++整数除法以及保留小数位的问题

    题目描述 Given two postive integers A and B,  please calculate the maximum integer C that C*B≤A, and the ...

  7. mongo db 分享 ppt

    在公司内部的mongo db的ppt.初步进阶 http://files.cnblogs.com/files/yuhan-TB/mongoDB.pptx

  8. (spring-第2回【IoC基础篇】)Spring的Schema,基于XML的配置

    要深入了解Spring机制,首先需要知道Spring是怎样在IoC容器中装配Bean的.而了解这一点的前提是,要搞清楚Spring基于Schema的Xml配置方案. 在深入了解之前,必须要先明白几个标 ...

  9. php大力力 [032节] php设计时候遇见麻烦:XQB50-H8268 进水电磁阀

    海信洗衣机 无法进水,刚才写程序,洗衣机不进水,在叫唤,去看了看,上网查了查,估计是进水电磁阀坏了. 打算自己拆了查出型号,淘宝买,自己修. 想起以前洗衣机坏了,找人修,对方报价好几百,淘宝看洗衣机主 ...

  10. Unix command 积累

    UNIX is a multi-user multitasking-optimized operating system that can run on various hardware platfo ...