我希望通过select查询,日期列表位于两个日期之间.例如:

如果我给出"2012-02-10"和"2012-02-15",我需要结果.

date      
----------
2012-02-10
2012-02-11
2012-02-12
2012-02-13
2012-02-14
2012-02-15 

我怎么才能得到?

推荐答案

try :

select * from 
(select adddate('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) selected_date from
 (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,
 (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1,
 (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,
 (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3,
 (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v
where selected_date between '2012-02-10' and '2012-02-15'

-在future 的近300年里.

[经UrvishAtSynapse建议编辑后更正.]

Mysql相关问答推荐

SQL Store Procedure Throwing [42000][1064]您在EXECUTE stat USING声明上的SQL语法中有错误

提高bash脚本从大型gml文件读取数据的效率

为什么用PyMySQL构建的json返回结果会出现重复?

替代对多个表执行 FULL OUTER JOIN?

Mysql根据文本语言或行数将列拆分为多列

从 MySQL WordPress Select 最后一行

仅当 SELECT 语句在 MySQL 中给出空集时才执行 UPDATE 语句

如何在 mysql 中获取 Day Wise 的平均值?

在 MySQL 中使用非空条件 LAG() 函数

在表中找到最大值,然后分别显示SQL组和每个SQL组中的最大值计数

mysql - 如何加入表中的动态列

是否可以在 macOS 上只安装 mysqldump

如何使用 SQL 数据库中的经纬度查找最近的位置?

Doctrine2 迁移向下迁移并从浏览器而不是命令行迁移

如何使用 XML_LOAD() 将 XML 文件导入 MySQL 数据库表;功能

MySQL术语约束与外键的区别?

如何将 mysqldump 的输出拆分为较小的文件?

Python 是否支持 MySQL 准备好的语句?

MySQLgo 除非数字字符进行比较

MySQL连接查询使用like?