<p>Is it possible to create a SQL query which will return one column which contains the dates from a given date range (e.g. all dates from last year till today). E.g.</p>

<pre><code>dat
----
2007-10-01
2007-10-02
2007-10-03
2007-10-04
...
</code></pre>

<p>I am wondering if this is possible as an alternative to creating a table which holds all those dates precalculated.</p>

<p><strong>Updated:</strong> I need a solution for MYSQL. I am not interested in any other DBs in this case.</p>

AFAIK you cannot do that with a single SQL query. However the following block of code will do the job.
Currently in Transact-SQL (for SQL Server). I do not know how this translates to MySQL.
```
```
DECLARE @start datetime
DECLARE @end datetime
DECLARE @results TABLE
(
   val datetime not null
)
set @start = '2008-10-01'
set @end = getdate()
while @start < @end
begin
    insert into @results values(@start)
    SELECT @start = DATEADD (d, 1, @start)
end
select val from @results
```
```
This outputs:
```
```
2008-10-01 00:00:00.000
2008-10-02 00:00:00.000
2008-10-03 00:00:00.000
```
```