求一sql
当给定开始日期和结束日期时,如何返回中间的所有日期比如
开始日期为 2010-03-01 结束日期为 2010-03-05然后返回的结果为下
2010-03-01
2010-03-02
2010-03-03
2010-03-04
2010-03-05

解决方案 »

  1.   

    创建一张表 tx(id int primary key); 然后 insert into tx values (1),(2),(3),...(500),..
    然后 
    select '2010-03-01'+interval id day
    from tx 
    where '2010-03-01'+interval id day <= '2010-03-05'
      

  2.   

    select * from table_name  t where  t.createTime>='2010-03-01' and t.createTime <='2010-03-05'
      

  3.   

    select * from table_name  t where  t.createTime between '2010-03-01' and '2010-03-05'
      

  4.   

    不是在表中查询日期,要求应该是用mysql中的函数根据输入的两个日期变量返回中间的所有日期
      

  5.   

    select date_add('2010-03-01',interval help_topic_id day) as 日期
    from mysql.help_topic 
    where date_add('2010-03-01',interval help_topic_id day)<='2010-03-05