我有这个表和数据如下所示
CREATE TABLE events_calender (
company_name varchar(30) DEFAULT NULL,
reg_date varchar(20)
);
Insert into events_calender values('Childerse Event' , '30-Oct-2015');
Insert into events_calender values('Womens Event' , '05-Nov-2015');
Insert into events_calender values('Mens Event' , '02-Nov-2015');
Insert into events_calender values('DOlls Event' , '02-Oct-2015');
我想将当天的数据返回到即将到来的7天(即将发生的事件)
我试过这种方式
来自events_calender的SELECT * 在哪里注册日期(现在())和日期(DATE_ADD(现在(),间隔7天))
但即使记录存在,也没有实际返回数据
答案 0 :(得分:0)
声明reg_date date
的错误类型应为CREATE TABLE events_calender (
company_name varchar(30) DEFAULT NULL,
reg_date date
);
Insert into events_calender values('Childerse Event' , '2015-10-30');
Insert into events_calender values('Womens Event' , '2015-11-05');
Insert into events_calender values('Mens Event' , '2015-11-02');
Insert into events_calender values('DOlls Event' , '2015-10-02');
SELECT *
FROM events_calender
WHERE reg_date BETWEEN DATE( NOW() ) AND DATE( DATE_ADD( NOW() , INTERVAL 7 DAY ) )
:
http://sqlfiddle.com/#!9/22cfe/1
{{1}}